From 9083976989ace707d50cf7cdeadf210d54a0dd36 Mon Sep 17 00:00:00 2001 From: JaniruTEC Date: Wed, 18 Nov 2020 00:46:24 +0100 Subject: [PATCH] Fixed #1409 by addig an additonal check --- .../common/mountpoint/IrregularUnmountCleaner.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/main/commons/src/main/java/org/cryptomator/common/mountpoint/IrregularUnmountCleaner.java b/main/commons/src/main/java/org/cryptomator/common/mountpoint/IrregularUnmountCleaner.java index d91fd0041..8be740fc3 100644 --- a/main/commons/src/main/java/org/cryptomator/common/mountpoint/IrregularUnmountCleaner.java +++ b/main/commons/src/main/java/org/cryptomator/common/mountpoint/IrregularUnmountCleaner.java @@ -48,6 +48,7 @@ public class IrregularUnmountCleaner { private static void deleteEmptyDir(Path dir) throws IOException { assert Files.isDirectory(dir, LinkOption.NOFOLLOW_LINKS); try { + checkEmpty(dir); Files.delete(dir); // attempt to delete dir non-recursively (will fail, if there are contents) } catch (DirectoryNotEmptyException e) { LOG.info("Found non-empty directory in mountpoint dir: {}", dir); @@ -61,4 +62,10 @@ public class IrregularUnmountCleaner { } } + private static void checkEmpty(Path dir) throws IOException { + if(Files.newDirectoryStream(dir).iterator().hasNext()) { + throw new DirectoryNotEmptyException(dir.toString()); + } + } + }