sessionTemporaryFolder.deleteOnExit();
}
// Launch a timer that updates modification date of the temporary folder each minute
final long updateDelay = 60000;
new Timer(true).schedule(new TimerTask() {
@Override
public void run() {
// Ensure modification date is always growing in case system time was adjusted
sessionTemporaryFolder.setLastModified(Math.max(System.currentTimeMillis(),
sessionTemporaryFolder.lastModified() + updateDelay));
}
}, updateDelay, updateDelay);
if (siblingTemporaryFolders != null
&& siblingTemporaryFolders.length > 0) {
// Launch a timer that will delete in 10 min temporary folders older than a week
final long deleteDelay = 10 * 60000;
final long age = 7 * 24 * 3600000;
new Timer(true).schedule(new TimerTask() {
@Override
public void run() {
long now = System.currentTimeMillis();
for (File siblingTemporaryFolder : siblingTemporaryFolders) {
if (siblingTemporaryFolder.exists()