Improve DEBUG during WebInfConfiguration.unpack
This commit is contained in:
parent
2803f5a872
commit
54aaa3a398
|
@ -472,6 +472,22 @@ public class IOTest
|
|||
assertFalse(IO.delete(noFile.toFile()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteTreeDeep(WorkDir workDir) throws IOException
|
||||
{
|
||||
Path dir = workDir.getEmptyPathDir();
|
||||
FS.ensureEmpty(dir);
|
||||
|
||||
Files.createDirectory(dir.resolve("foo"));
|
||||
Files.createDirectory(dir.resolve("foo/bar"));
|
||||
Files.createDirectory(dir.resolve("foo/zed"));
|
||||
Files.createDirectory(dir.resolve("foo/zed/one"));
|
||||
Files.writeString(dir.resolve("foo/bar/test.txt"), "Test");
|
||||
Files.writeString(dir.resolve("foo/zed/one/test.txt"), "Test");
|
||||
|
||||
assertTrue(IO.delete(dir));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsEmptyNull()
|
||||
{
|
||||
|
|
|
@ -380,6 +380,12 @@ public class IO
|
|||
return file.delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the path, recursively.
|
||||
*
|
||||
* @param path the path to delete
|
||||
* @return true if able to delete the path, false if unable to delete the path.
|
||||
*/
|
||||
public static boolean delete(Path path)
|
||||
{
|
||||
if (path == null)
|
||||
|
@ -406,6 +412,8 @@ public class IO
|
|||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Unable to delete path: {}", path, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -291,8 +291,17 @@ public class WebInfConfiguration extends AbstractConfiguration
|
|||
if (originalWarResource.lastModified().isAfter(Files.getLastModifiedTime(extractedWebAppDir).toInstant()) || extractionLock.exists())
|
||||
{
|
||||
extractionLock.createNewFile();
|
||||
IO.delete(extractedWebAppDir);
|
||||
Files.createDirectory(extractedWebAppDir);
|
||||
// Best effort delete
|
||||
if (IO.delete(extractedWebAppDir))
|
||||
{
|
||||
// Recreate the directory if it was deleted.
|
||||
Files.createDirectory(extractedWebAppDir);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LOG.isInfoEnabled())
|
||||
LOG.info("Unable to delete path {}, reusing existing path", extractedWebAppDir);
|
||||
}
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Extract {} to {}", webApp, extractedWebAppDir);
|
||||
try (ResourceFactory.Closeable resourceFactory = ResourceFactory.closeable())
|
||||
|
|
|
@ -293,8 +293,17 @@ public class WebInfConfiguration extends AbstractConfiguration
|
|||
if (originalWarResource.lastModified().isAfter(Files.getLastModifiedTime(extractedWebAppDir).toInstant()) || extractionLock.exists())
|
||||
{
|
||||
extractionLock.createNewFile();
|
||||
IO.delete(extractedWebAppDir);
|
||||
Files.createDirectory(extractedWebAppDir);
|
||||
// Best effort delete
|
||||
if (IO.delete(extractedWebAppDir))
|
||||
{
|
||||
// Recreate the directory if it was deleted.
|
||||
Files.createDirectory(extractedWebAppDir);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LOG.isInfoEnabled())
|
||||
LOG.info("Unable to delete path {}, reusing existing path", extractedWebAppDir);
|
||||
}
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Extract {} to {}", webApp, extractedWebAppDir);
|
||||
try (ResourceFactory.Closeable resourceFactory = ResourceFactory.closeable())
|
||||
|
|
Loading…
Reference in New Issue