Skip to content

Commit

Permalink
make sure that already-migrated files won't be affected by re-started…
Browse files Browse the repository at this point in the history
… migration from version 6 → 7
  • Loading branch information
overheadhunter committed Oct 13, 2019
1 parent b266343 commit bf6f040
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ class FilePathMigration {
public static Optional<FilePathMigration> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down

0 comments on commit bf6f040

Please sign in to comment.