From bf6f040d0bbba15a098a42b22004002e5957629f Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Sun, 13 Oct 2019 14:26:20 +0200 Subject: [PATCH] =?UTF-8?q?make=20sure=20that=20already-migrated=20files?= =?UTF-8?q?=20won't=20be=20affected=20by=20re-started=20migration=20from?= =?UTF-8?q?=20version=206=20=E2=86=92=207?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cryptofs/migration/v7/FilePathMigration.java | 6 +++++- .../cryptofs/migration/v7/FilePathMigrationTest.java | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/cryptomator/cryptofs/migration/v7/FilePathMigration.java b/src/main/java/org/cryptomator/cryptofs/migration/v7/FilePathMigration.java index 58f8246e..4a08097d 100644 --- a/src/main/java/org/cryptomator/cryptofs/migration/v7/FilePathMigration.java +++ b/src/main/java/org/cryptomator/cryptofs/migration/v7/FilePathMigration.java @@ -64,7 +64,11 @@ class FilePathMigration { public static Optional parse(Path vaultRoot, Path oldPath) throws IOException { final String oldFileName = oldPath.getFileName().toString(); final String canonicalOldFileName; - if (oldFileName.endsWith(OLD_SHORTENED_FILENAME_SUFFIX)) { + if (oldFileName.endsWith(NEW_REGULAR_SUFFIX) || oldFileName.endsWith(NEW_SHORTENED_SUFFIX)) { + // make sure to not match already migrated files + // (since BASE32 is a subset of BASE64, pure pattern matching could accidentally match those) + return Optional.empty(); + } else if (oldFileName.endsWith(OLD_SHORTENED_FILENAME_SUFFIX)) { Matcher matcher = OLD_SHORTENED_FILENAME_PATTERN.matcher(oldFileName); if (matcher.find()) { canonicalOldFileName = inflate(vaultRoot, matcher.group() + OLD_SHORTENED_FILENAME_SUFFIX); diff --git a/src/test/java/org/cryptomator/cryptofs/migration/v7/FilePathMigrationTest.java b/src/test/java/org/cryptomator/cryptofs/migration/v7/FilePathMigrationTest.java index 40901245..e2962915 100644 --- a/src/test/java/org/cryptomator/cryptofs/migration/v7/FilePathMigrationTest.java +++ b/src/test/java/org/cryptomator/cryptofs/migration/v7/FilePathMigrationTest.java @@ -189,6 +189,8 @@ public void testInflate(String canonicalLongFileName, String metadataFilePath, S @ValueSource(strings = { "00/000000000000000000000000000000/.DS_Store", "00/000000000000000000000000000000/foo", + "00/000000000000000000000000000000/ORSXG5A=.c9r", // already migrated + "00/000000000000000000000000000000/ORSXG5A=.c9s", // already migrated "00/000000000000000000000000000000/ORSXG5A", // removed one char "00/000000000000000000000000000000/NTJDZUB3J5S25LGO7CD4TE5VOJCSW7H.lng", // removed one char })