Old working directories are not removed
TovarischZhukov opened this issue · 2 comments
- When a working directory is created, it is created outside the parent directory.
if (builderDataDirectory == null) { builderDataDirectory = Files.createTempDirectory("epg").toFile(); }
But at the moment when a search is performed for obsolete ones, their path is calculated relative to the parent.
private void cleanOldDataDirectories(File parentDirectory) { final File[] children = parentDirectory.listFiles();
- If we still find such a directory, we try to take the lock, but without releasing it, we delete the folder, an exception occurs
try (FileOutputStream fos = new FileOutputStream(lockFile); FileLock lock = fos.getChannel().tryLock()) { if (lock != null) { //..... FileUtils.deleteDirectory(dir); } }
- Sometimes, when the test ends abnormally, the "epg-lock" file is not created, so these folders are also not cleared during subsequent runs.
final File lockFile = new File(dir, LOCK_FILE_NAME); final boolean isTooNew = System.currentTimeMillis() - lockFile.lastModified() < 10 * 60 * 1000; if (!lockFile.exists() || isTooNew) { continue; }
Just noticed this today as well.
I can attempt to fix this if you'd like?
If you have an idea how to fix it, help is always welcome.