Improved directory cleanup process to avoid leaving empty parent directories lying around.

This commit is contained in:
CalDescent 2021-12-05 16:24:47 +00:00
parent ffe178c64c
commit 007f567c7a

View File

@ -156,15 +156,8 @@ public class FilesystemUtils {
} }
if (cleanup) { if (cleanup) {
// Delete the parent directory if it is empty (and exists in our data/temp directory) // Delete the parent directories if they are empty (and exist in our data/temp directory)
Path parentDirectory = path.getParent(); FilesystemUtils.safeDeleteEmptyParentDirectories(path);
if (FilesystemUtils.pathInsideDataOrTempPath(parentDirectory)) {
try {
Files.deleteIfExists(parentDirectory);
} catch (IOException e) {
// This part is optional, so ignore failures
}
}
} }
} }