378242 Re-extract war on restart if incomplete extraction

Also removed unneeded .active files (used by a jetty-6 feature to try to overcome sun bug on tmp files not being deleted on windows that has not been ported to jetty-7)
This commit is contained in:
Jan Bartel 2012-05-02 15:01:08 +02:00
parent d0825239af
commit b131a0b30b
1 changed files with 11 additions and 7 deletions

View File

@ -369,10 +369,6 @@ public class WebInfConfiguration extends AbstractConfiguration
if (!isTempWorkDirectory(tmpDir))
{
tmpDir.deleteOnExit();
//TODO why is this here?
File sentinel = new File(tmpDir, ".active");
if(!sentinel.exists())
sentinel.mkdir();
}
if(LOG.isDebugEnabled())
@ -448,24 +444,32 @@ public class WebInfConfiguration extends AbstractConfiguration
}
else
{
//Use a sentinel file that will exist only whilst the extraction is taking place.
//This will help us detect interrupted extractions.
File extractionLock = new File (context.getTempDirectory(), ".extract_lock");
if (!extractedWebAppDir.exists())
{
//it hasn't been extracted before so extract it
extractionLock.createNewFile();
extractedWebAppDir.mkdir();
LOG.info("Extract " + web_app + " to " + extractedWebAppDir);
LOG.info("Extract " + web_app + " to " + extractedWebAppDir);
Resource jar_web_app = JarResource.newJarResource(web_app);
jar_web_app.copyTo(extractedWebAppDir);
extractionLock.delete();
}
else
{
//only extract if the war file is newer
if (web_app.lastModified() > extractedWebAppDir.lastModified())
//only extract if the war file is newer, or a .extract_lock file is left behind meaning a possible partial extraction
if (web_app.lastModified() > extractedWebAppDir.lastModified() || extractionLock.exists())
{
extractionLock.createNewFile();
IO.delete(extractedWebAppDir);
extractedWebAppDir.mkdir();
LOG.info("Extract " + web_app + " to " + extractedWebAppDir);
Resource jar_web_app = JarResource.newJarResource(web_app);
jar_web_app.copyTo(extractedWebAppDir);
extractionLock.delete();
}
}
}