diff --git a/src/main/java/org/cryptomator/cryptofs/CryptoFileSystemImpl.java b/src/main/java/org/cryptomator/cryptofs/CryptoFileSystemImpl.java index 8bd83d2d..8a69c831 100644 --- a/src/main/java/org/cryptomator/cryptofs/CryptoFileSystemImpl.java +++ b/src/main/java/org/cryptomator/cryptofs/CryptoFileSystemImpl.java @@ -621,18 +621,18 @@ private void moveDirectory(CryptoPath cleartextSource, CryptoPath cleartextTarge throw new AtomicMoveNotSupportedException(cleartextSource.toString(), cleartextTarget.toString(), "Replacing directories during move requires non-atomic status checks."); } // check if dir is empty: - Path oldCiphertextDir = cryptoPathMapper.getCiphertextDir(cleartextTarget).path; - boolean oldCiphertextDirExists = true; - try (DirectoryStream ds = Files.newDirectoryStream(oldCiphertextDir)) { + Path targetCiphertextDirContentDir = cryptoPathMapper.getCiphertextDir(cleartextTarget).path; + boolean targetCiphertextDirExists = true; + try (DirectoryStream ds = Files.newDirectoryStream(targetCiphertextDirContentDir)) { if (ds.iterator().hasNext()) { throw new DirectoryNotEmptyException(cleartextTarget.toString()); } } catch (NoSuchFileException e) { - oldCiphertextDirExists = false; + targetCiphertextDirExists = false; } // cleanup dir to be replaced: - if (oldCiphertextDirExists) { - Files.walkFileTree(oldCiphertextDir, DeletingFileVisitor.INSTANCE); + if (targetCiphertextDirExists) { + Files.walkFileTree(targetCiphertextDirContentDir, DeletingFileVisitor.INSTANCE); } Files.walkFileTree(ciphertextTarget.getRawPath(), DeletingFileVisitor.INSTANCE); }