Skip to content

Commit cf4fe14

Browse files
committed
construct all dirIdCheck results with vault relative paths
1 parent 855b342 commit cf4fe14

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

src/main/java/org/cryptomator/cryptofs/health/dirid/DirIdCheck.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,11 @@ public void check(Path pathToVault, VaultConfig config, Masterkey masterkey, Cry
6161
boolean foundDir = dirVisitor.secondLevelDirs.remove(expectedDir);
6262
if (foundDir) {
6363
iter.remove();
64-
if (Files.exists(dataDirPath.resolve(expectedDir).resolve(Constants.DIR_BACKUP_FILE_NAME))) {
65-
resultCollector.accept(new HealthyDir(dirId, dirFile, expectedDir));
64+
var expectedDirVaultRel = Path.of(Constants.DATA_DIR_NAME).resolve(expectedDir);
65+
if (Files.exists(pathToVault.resolve(expectedDir).resolve(Constants.DIR_BACKUP_FILE_NAME))) {
66+
resultCollector.accept(new HealthyDir(dirId, dirFile, expectedDirVaultRel));
6667
} else {
67-
resultCollector.accept(new MissingDirIdBackup(dirId, expectedDir));
68+
resultCollector.accept(new MissingDirIdBackup(dirId, expectedDirVaultRel));
6869
}
6970
}
7071
}

src/main/java/org/cryptomator/cryptofs/health/dirid/MissingDirIdBackup.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public String toString() {
2929

3030
//visible for testing
3131
void fix(Path pathToVault, Cryptor cryptor) throws IOException {
32-
Path absCipherDir = pathToVault.resolve(Constants.DATA_DIR_NAME).resolve(contentDir);
32+
Path absCipherDir = pathToVault.resolve(contentDir);
3333
DirectoryIdBackup.backupManually(cryptor, new CryptoPathMapper.CiphertextDirectory(dirId, absCipherDir));
3434
}
3535

src/test/java/org/cryptomator/cryptofs/health/dirid/MissingDirIdBackupTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public void testGetFix() {
3333
@DisplayName("The fix calls dirId backup class with correct parameters")
3434
@Test
3535
public void testFix() throws IOException {
36-
Path cipherDir = Path.of("ri/diculous-30-char-pseudo-hash");
36+
Path cipherDir = Path.of("d/ri/diculous-30-char-pseudo-hash");
3737
String dirId = "1234-456789-1234";
3838
try (var dirIdBackupMock = Mockito.mockStatic(DirectoryIdBackup.class)) {
3939
dirIdBackupMock.when(() -> DirectoryIdBackup.backupManually(Mockito.any(), Mockito.any())).thenAnswer(Answers.RETURNS_SMART_NULLS);
@@ -42,7 +42,7 @@ public void testFix() throws IOException {
4242
result = new MissingDirIdBackup(dirId, cipherDir);
4343
result.fix(pathToVault, cryptor);
4444

45-
var expectedPath = pathToVault.resolve("d").resolve(cipherDir);
45+
var expectedPath = pathToVault.resolve(cipherDir);
4646
ArgumentMatcher<CryptoPathMapper.CiphertextDirectory> cipherDirMatcher = obj -> obj.dirId.equals(dirId) && obj.path.isAbsolute() && obj.path.equals(expectedPath);
4747
dirIdBackupMock.verify(() -> DirectoryIdBackup.backupManually(Mockito.eq(cryptor), Mockito.argThat(cipherDirMatcher)), Mockito.times(1));
4848
}

0 commit comments

Comments
 (0)