diff --git a/main/ant-kit/pom.xml b/main/ant-kit/pom.xml
index d5bfd3e60..389fa3f63 100644
--- a/main/ant-kit/pom.xml
+++ b/main/ant-kit/pom.xml
@@ -8,7 +8,7 @@
org.cryptomator
main
- 1.1.1
+ 1.1.2
ant-kit
pom
diff --git a/main/commons-test/pom.xml b/main/commons-test/pom.xml
index 653c8c7ac..9ae5f7b44 100644
--- a/main/commons-test/pom.xml
+++ b/main/commons-test/pom.xml
@@ -10,7 +10,7 @@
org.cryptomator
main
- 1.1.1
+ 1.1.2
commons-test
Cryptomator common test dependencies
diff --git a/main/commons/pom.xml b/main/commons/pom.xml
index aa5c7fb0f..735adf23d 100644
--- a/main/commons/pom.xml
+++ b/main/commons/pom.xml
@@ -10,7 +10,7 @@
org.cryptomator
main
- 1.1.1
+ 1.1.2
commons
Cryptomator common
diff --git a/main/filesystem-api/pom.xml b/main/filesystem-api/pom.xml
index 24d0b0964..3ae610104 100644
--- a/main/filesystem-api/pom.xml
+++ b/main/filesystem-api/pom.xml
@@ -9,7 +9,7 @@
org.cryptomator
main
- 1.1.1
+ 1.1.2
filesystem-api
Cryptomator filesystem: API
diff --git a/main/filesystem-charsets/pom.xml b/main/filesystem-charsets/pom.xml
index 5fba8cc14..11fafb0fb 100644
--- a/main/filesystem-charsets/pom.xml
+++ b/main/filesystem-charsets/pom.xml
@@ -12,7 +12,7 @@
org.cryptomator
main
- 1.1.1
+ 1.1.2
filesystem-charsets
Cryptomator filesystem: Charset compatibility layer
diff --git a/main/filesystem-crypto-integration-tests/pom.xml b/main/filesystem-crypto-integration-tests/pom.xml
index 54261c2dd..41638bf90 100644
--- a/main/filesystem-crypto-integration-tests/pom.xml
+++ b/main/filesystem-crypto-integration-tests/pom.xml
@@ -12,7 +12,7 @@
org.cryptomator
main
- 1.1.1
+ 1.1.2
filesystem-crypto-integration-tests
Cryptomator filesystem: Encryption layer tests
diff --git a/main/filesystem-crypto/pom.xml b/main/filesystem-crypto/pom.xml
index fa43feba1..1111a90cb 100644
--- a/main/filesystem-crypto/pom.xml
+++ b/main/filesystem-crypto/pom.xml
@@ -12,7 +12,7 @@
org.cryptomator
main
- 1.1.1
+ 1.1.2
filesystem-crypto
Cryptomator filesystem: Encryption layer
diff --git a/main/filesystem-crypto/src/main/java/org/cryptomator/filesystem/crypto/ConflictResolver.java b/main/filesystem-crypto/src/main/java/org/cryptomator/filesystem/crypto/ConflictResolver.java
index 19dceb326..6b8a1f428 100644
--- a/main/filesystem-crypto/src/main/java/org/cryptomator/filesystem/crypto/ConflictResolver.java
+++ b/main/filesystem-crypto/src/main/java/org/cryptomator/filesystem/crypto/ConflictResolver.java
@@ -2,6 +2,7 @@ package org.cryptomator.filesystem.crypto;
import static org.cryptomator.filesystem.crypto.Constants.DIR_PREFIX;
+import java.nio.ByteBuffer;
import java.util.Optional;
import java.util.UUID;
import java.util.function.Function;
@@ -12,7 +13,7 @@ import java.util.regex.Pattern;
import org.apache.commons.lang3.StringUtils;
import org.cryptomator.filesystem.File;
import org.cryptomator.filesystem.Folder;
-import org.cryptomator.io.FileContents;
+import org.cryptomator.filesystem.ReadableFile;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -20,6 +21,7 @@ final class ConflictResolver {
private static final Logger LOG = LoggerFactory.getLogger(ConflictResolver.class);
private static final int UUID_FIRST_GROUP_STRLEN = 8;
+ private static final int MAX_DIR_FILE_SIZE = 87; // "normal" file header has 88 bytes
private final Pattern encryptedNamePattern;
private final Function> nameDecryptor;
@@ -52,13 +54,11 @@ final class ConflictResolver {
if (cleartext.isPresent()) {
Folder folder = conflictingFile.parent().get();
File canonicalFile = folder.file(isDirectory ? DIR_PREFIX + ciphertext : ciphertext);
- if (canonicalFile.exists()) {
+ if (isDirectory && canonicalFile.exists() && isSameFileBasedOnSample(canonicalFile, conflictingFile, MAX_DIR_FILE_SIZE)) {
// there must not be two directories pointing to the same directory id. In this case no human interaction is needed to resolve this conflict:
- if (isDirectory && FileContents.UTF_8.readContents(canonicalFile).equals(FileContents.UTF_8.readContents(conflictingFile))) {
- conflictingFile.delete();
- return canonicalFile;
- }
-
+ conflictingFile.delete();
+ return canonicalFile;
+ } else {
// conventional conflict detected! look for an alternative name:
File alternativeFile;
String conflictId;
@@ -71,9 +71,6 @@ final class ConflictResolver {
LOG.info("Detected conflict {}:\n{}\n{}", conflictId, canonicalFile, conflictingFile);
conflictingFile.moveTo(alternativeFile);
return alternativeFile;
- } else {
- conflictingFile.moveTo(canonicalFile);
- return canonicalFile;
}
} else {
// not decryptable; false positive
@@ -81,6 +78,22 @@ final class ConflictResolver {
}
}
+ private boolean isSameFileBasedOnSample(File file1, File file2, int sampleSize) {
+ try (ReadableFile r1 = file1.openReadable(); ReadableFile r2 = file2.openReadable()) {
+ if (r1.size() != r2.size()) {
+ return false;
+ } else {
+ ByteBuffer beginOfFile1 = ByteBuffer.allocate(sampleSize);
+ ByteBuffer beginOfFile2 = ByteBuffer.allocate(sampleSize);
+ r1.read(beginOfFile1);
+ r2.read(beginOfFile2);
+ beginOfFile1.flip();
+ beginOfFile2.flip();
+ return beginOfFile1.equals(beginOfFile2);
+ }
+ }
+ }
+
private String createConflictId() {
return UUID.randomUUID().toString().substring(0, UUID_FIRST_GROUP_STRLEN);
}
diff --git a/main/filesystem-inmemory/pom.xml b/main/filesystem-inmemory/pom.xml
index e0a5f3610..c86c0abf0 100644
--- a/main/filesystem-inmemory/pom.xml
+++ b/main/filesystem-inmemory/pom.xml
@@ -12,7 +12,7 @@
org.cryptomator
main
- 1.1.1
+ 1.1.2
filesystem-inmemory
Cryptomator filesystem: In-memory mock
diff --git a/main/filesystem-invariants-tests/pom.xml b/main/filesystem-invariants-tests/pom.xml
index 7c394c5b7..1012ae262 100644
--- a/main/filesystem-invariants-tests/pom.xml
+++ b/main/filesystem-invariants-tests/pom.xml
@@ -9,7 +9,7 @@
org.cryptomator
main
- 1.1.1
+ 1.1.2
filesystem-invariants-tests
Cryptomator filesystem: Invariants tests
diff --git a/main/filesystem-nameshortening/pom.xml b/main/filesystem-nameshortening/pom.xml
index 28f991d94..01e49e620 100644
--- a/main/filesystem-nameshortening/pom.xml
+++ b/main/filesystem-nameshortening/pom.xml
@@ -12,7 +12,7 @@
org.cryptomator
main
- 1.1.1
+ 1.1.2
filesystem-nameshortening
Cryptomator filesystem: Name shortening layer
diff --git a/main/filesystem-nio/pom.xml b/main/filesystem-nio/pom.xml
index b8c32607a..be2e94afb 100644
--- a/main/filesystem-nio/pom.xml
+++ b/main/filesystem-nio/pom.xml
@@ -7,7 +7,7 @@
org.cryptomator
main
- 1.1.1
+ 1.1.2
filesystem-nio
Cryptomator filesystem: NIO-based physical layer
diff --git a/main/filesystem-stats/pom.xml b/main/filesystem-stats/pom.xml
index ebdabe7cd..95191d908 100644
--- a/main/filesystem-stats/pom.xml
+++ b/main/filesystem-stats/pom.xml
@@ -12,7 +12,7 @@
org.cryptomator
main
- 1.1.1
+ 1.1.2
filesystem-stats
Cryptomator filesystem: Throughput statistics
diff --git a/main/frontend-api/pom.xml b/main/frontend-api/pom.xml
index edcf07328..e4ee5ccef 100644
--- a/main/frontend-api/pom.xml
+++ b/main/frontend-api/pom.xml
@@ -12,7 +12,7 @@
org.cryptomator
main
- 1.1.1
+ 1.1.2
frontend-api
Cryptomator frontend: API
diff --git a/main/frontend-webdav/pom.xml b/main/frontend-webdav/pom.xml
index d1b76702b..cbe911efc 100644
--- a/main/frontend-webdav/pom.xml
+++ b/main/frontend-webdav/pom.xml
@@ -12,7 +12,7 @@
org.cryptomator
main
- 1.1.1
+ 1.1.2
frontend-webdav
Cryptomator frontend: WebDAV frontend
diff --git a/main/jacoco-report/pom.xml b/main/jacoco-report/pom.xml
index b21465f5c..1ec3a7e0c 100644
--- a/main/jacoco-report/pom.xml
+++ b/main/jacoco-report/pom.xml
@@ -5,7 +5,7 @@
org.cryptomator
main
- 1.1.1
+ 1.1.2
jacoco-report
Cryptomator Code Coverage Report
diff --git a/main/pom.xml b/main/pom.xml
index 0f70d765e..95df83ce3 100644
--- a/main/pom.xml
+++ b/main/pom.xml
@@ -7,7 +7,7 @@
4.0.0
org.cryptomator
main
- 1.1.1
+ 1.1.2
pom
Cryptomator
diff --git a/main/uber-jar/pom.xml b/main/uber-jar/pom.xml
index e0ffdb58f..4ed59da11 100644
--- a/main/uber-jar/pom.xml
+++ b/main/uber-jar/pom.xml
@@ -12,7 +12,7 @@
org.cryptomator
main
- 1.1.1
+ 1.1.2
uber-jar
pom
diff --git a/main/ui/pom.xml b/main/ui/pom.xml
index c8d7fd8e5..cf4bcea5f 100644
--- a/main/ui/pom.xml
+++ b/main/ui/pom.xml
@@ -12,7 +12,7 @@
org.cryptomator
main
- 1.1.1
+ 1.1.2
ui
Cryptomator GUI