Skip to content

Commit

Permalink
resolve TODO
Browse files Browse the repository at this point in the history
  • Loading branch information
infeo committed Jan 9, 2025
1 parent eb78338 commit 8e72527
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/main/java/org/cryptomator/cryptofs/FileNameDecryptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,11 @@ boolean hasCipherNodeExtension(Path p) {
return name != null && Stream.of(Constants.CRYPTOMATOR_FILE_SUFFIX, Constants.DEFLATED_FILE_SUFFIX).anyMatch(name.toString()::endsWith);
}

boolean isAtCipherNodeLevel(Path p) {
return vaultPath.relativize(p).getNameCount() == 4; //TODO: relativize is defined for two relative Paths. For two absolute paths, the result depends on the OS
boolean isAtCipherNodeLevel(Path absolutPah) {
if (!absolutPah.isAbsolute()) {
throw new IllegalArgumentException("Path " + absolutPah + "must be absolute");
}
return absolutPah.subpath(vaultPath.getNameCount(), absolutPah.getNameCount()).getNameCount() == 4;
}

boolean hasMinimumFileNameLength(Path p) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,5 +167,10 @@ public void validateTooShort() {
}
}

@Test
public void testIsAtCipherNodeLevelRequiresAbsolutePath() {
Assertions.assertThrows(IllegalArgumentException.class, () -> testObj.isAtCipherNodeLevel(Path.of("relative/path")));
}


}

0 comments on commit 8e72527

Please sign in to comment.