Skip to content

Commit bf6f040

Browse files
make sure that already-migrated files won't be affected by re-started migration from version 6 → 7
1 parent b266343 commit bf6f040

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/main/java/org/cryptomator/cryptofs/migration/v7/FilePathMigration.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ class FilePathMigration {
6464
public static Optional<FilePathMigration> parse(Path vaultRoot, Path oldPath) throws IOException {
6565
final String oldFileName = oldPath.getFileName().toString();
6666
final String canonicalOldFileName;
67-
if (oldFileName.endsWith(OLD_SHORTENED_FILENAME_SUFFIX)) {
67+
if (oldFileName.endsWith(NEW_REGULAR_SUFFIX) || oldFileName.endsWith(NEW_SHORTENED_SUFFIX)) {
68+
// make sure to not match already migrated files
69+
// (since BASE32 is a subset of BASE64, pure pattern matching could accidentally match those)
70+
return Optional.empty();
71+
} else if (oldFileName.endsWith(OLD_SHORTENED_FILENAME_SUFFIX)) {
6872
Matcher matcher = OLD_SHORTENED_FILENAME_PATTERN.matcher(oldFileName);
6973
if (matcher.find()) {
7074
canonicalOldFileName = inflate(vaultRoot, matcher.group() + OLD_SHORTENED_FILENAME_SUFFIX);

src/test/java/org/cryptomator/cryptofs/migration/v7/FilePathMigrationTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ public void testInflate(String canonicalLongFileName, String metadataFilePath, S
189189
@ValueSource(strings = {
190190
"00/000000000000000000000000000000/.DS_Store",
191191
"00/000000000000000000000000000000/foo",
192+
"00/000000000000000000000000000000/ORSXG5A=.c9r", // already migrated
193+
"00/000000000000000000000000000000/ORSXG5A=.c9s", // already migrated
192194
"00/000000000000000000000000000000/ORSXG5A", // removed one char
193195
"00/000000000000000000000000000000/NTJDZUB3J5S25LGO7CD4TE5VOJCSW7H.lng", // removed one char
194196
})

0 commit comments

Comments
 (0)