From e48481323373f879f7f3a556e93c32b95ace2908 Mon Sep 17 00:00:00 2001 From: JaniruTEC <52893617+JaniruTEC@users.noreply.github.com> Date: Fri, 7 Jul 2023 16:19:16 +0200 Subject: [PATCH] Added check for deletion of hideaway --- .../common/mount/MountWithinParentUtil.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/cryptomator/common/mount/MountWithinParentUtil.java b/src/main/java/org/cryptomator/common/mount/MountWithinParentUtil.java index 2aa9feadc..f203a359f 100644 --- a/src/main/java/org/cryptomator/common/mount/MountWithinParentUtil.java +++ b/src/main/java/org/cryptomator/common/mount/MountWithinParentUtil.java @@ -72,12 +72,24 @@ public final class MountWithinParentUtil { Path hideaway = getHideaway(mountPoint); try { waitForMountpointRestoration(mountPoint); + if (Files.notExists(hideaway, LinkOption.NOFOLLOW_LINKS)) { + LOG.error("Unable to restore hidden directory to mountpoint \"{}\": Directory does not exist. (Deleted by user?)", mountPoint); + return; + } + if (!Files.isDirectory(hideaway, LinkOption.NOFOLLOW_LINKS)) { + LOG.error("Unable to restore hidden directory to mountpoint \"{}\": Not a directory.", mountPoint); + if (SystemUtils.IS_OS_WINDOWS) { + Files.setAttribute(hideaway, WIN_HIDDEN_ATTR, false); + } + return; + } + Files.move(hideaway, mountPoint); if (SystemUtils.IS_OS_WINDOWS) { Files.setAttribute(mountPoint, WIN_HIDDEN_ATTR, false); } } catch (IOException e) { - LOG.error("Unable to restore hidden directory to mountpoint {}.", mountPoint, e); + LOG.error("Unable to restore hidden directory to mountpoint \"{}\".", mountPoint, e); } }