On 17 Feb 2015 at 14:52:17, Thomas Mortagne
(thomas.mortagne@xwiki.com(mailto:thomas.mortagne@xwiki.com)) wrote:
On Tue, Feb 17, 2015 at 2:42 PM,
vincent(a)massol.net wrote:
On 17 Feb 2015 at 14:14:36, Thomas Mortagne
(thomas.mortagne@xwiki.com(mailto:thomas.mortagne@xwiki.com)) wrote:
On Tue, Feb 17, 2015 at 2:04 PM,
vincent(a)massol.net wrote:
> Just to be clear: I’m -1 till I understand why we need a new concept and why
deciding where we put our temporary directory is not good enough.
>
> To summarize my position:
> * Cache files are temporary files. They can be recreated. And it’s not because files
are in a temporary folder that they have to be deleted every few minutes :)
> * In order to prevent some process to mess with our temp files when XWiki is running
(for ex) we could want to control where we put our temporary directory. This is already
configurable and doable
Temporary directory is not configurable at XWiki level so it depends
on the application server.
Yes I know and the idea would be to introduce a configuration property in
xwiki.properties to set the temporary directory in case the user wants to change it.
FTR I’ve checked Jetty/Tomcat:
* By default recent versions of jetty use the java.io.tmdir by default if not set. We
could easily set it in our standalone distribution (we used to have a jetty/temp dir
AFAIR). Also not that by default Jetty cleans the temp dir at each restart unless you tell
it not to or unless you put your tmp dir inside a work directory. See see
http://eclipse.org/jetty/documentation/current/ref-temporary-directories.ht…. Note that
the work dir in jetty is just there for backward compat and jetty only uses a temp dir now
apparently.
* Tomcat has the 2 notions of work and temp directories. I don’t think it cleans the temp
directory automatically at each restart though.
So we have 2 options:
Option 1: we don’t introduce a new concept and we just make our temporary directory
configurable
Option 2: we do the same as tomcat and introduce a concept of work/cache directory. I
think I prefer “work” over “cache” if I have to choose since it’s less restrictive. In
this case the difference is small:
- temporary directory: anything in there can (and this is what happens with a default,
non-configured jetty) be removed between restarts of the container without impacting
anything at runtime (no performance degradation for example). This is really used for
short-lived temporary files that should be removed when the container stops.
- work/cache directory: files that can be removed without endangering the runtime
execution of XWiki but it must not be removed at each container restart. Should be removed
when performing an XWiki upgrade though.
Where would we put where:
- work dir: solr/lucene indexes, LESS cache,
image resizes, chart-generated images, aether cache, formula-generates images, office
viewer, graphviz image cache, svg image cache, TempResourceAction
(there is no such thing as aether cache since 6.0)
I did a search to find all the places we use getTemporaryDirectory() and found this:
public class DefaultAetherConfiguration implements AetherConfiguration
{
[…]
@Override
public File getLocalRepository()
{
String localRepositoryPath =
this.configurationSourceProvider.get().getProperty("extension.aether.localRepository");
File directory;
if (localRepositoryPath == null) {
directory = new File(this.environment.getTemporaryDirectory(),
"aether-repository");
} else {
So it does seem we still use the temporary directory for something.