embedded-postgres icon indicating copy to clipboard operation
embedded-postgres copied to clipboard

Old working directories are not removed

Open TovarischZhukov opened this issue 4 years ago • 2 comments

  1. 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();

  1. 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); } }

  1. 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; }

TovarischZhukov avatar Sep 28 '21 07:09 TovarischZhukov

Just noticed this today as well. I can attempt to fix this if you'd like?

rasharab avatar Apr 21 '23 20:04 rasharab

If you have an idea how to fix it, help is always welcome.

tomix26 avatar May 15 '23 22:05 tomix26