Open paeppa opened 6 years ago
Would be great if cryptofs would also allow hard-links on disc. I made a "proof-of-concept" implementation (see patch attached) which only adds about 10 lines of code.
diff --git a/src/main/java/org/cryptomator/cryptofs/CryptoFileSystemImpl.java b/src/main/java/org/cryptomator/cryptofs/CryptoFileSystemImpl.java index 3c84460..0fa5077 100644 --- a/src/main/java/org/cryptomator/cryptofs/CryptoFileSystemImpl.java +++ b/src/main/java/org/cryptomator/cryptofs/CryptoFileSystemImpl.java @@ -403,6 +403,12 @@ throw new NoSuchFileException(cleartextSource.toString()); } } + + void link(CryptoPath cleartextLink, CryptoPath cleartextExisting) throws IOException { + Path ciphertextLinkFile = cryptoPathMapper.getCiphertextFilePath(cleartextLink, CiphertextFileType.FILE); + Path ciphertextExistingFile = cryptoPathMapper.getCiphertextFilePath(cleartextExisting, CiphertextFileType.FILE); + Files.createLink(ciphertextLinkFile, ciphertextExistingFile); + } private void copyAttributes(Path src, Path dst) throws IOException { Set<Class<? extends FileAttributeView>> supportedAttributeViewTypes = fileStore.supportedFileAttributeViewTypes(); diff --git a/src/main/java/org/cryptomator/cryptofs/CryptoFileSystemProvider.java b/src/main/java/org/cryptomator/cryptofs/CryptoFileSystemProvider.java index ea9595a..3627e68 100644 --- a/src/main/java/org/cryptomator/cryptofs/CryptoFileSystemProvider.java +++ b/src/main/java/org/cryptomator/cryptofs/CryptoFileSystemProvider.java @@ -383,4 +383,9 @@ } } + @Override + public void createLink(Path link, Path existing) throws IOException { + fileSystem(existing).link(CryptoPath.castAndAssertAbsolute(link), CryptoPath.castAndAssertAbsolute(existing)); + } + }
Would be great if cryptofs would also allow hard-links on disc. I made a "proof-of-concept" implementation (see patch attached) which only adds about 10 lines of code.