cryptomator / cryptomator/cryptofs

Allow hard-links to be created

Open
#19 0 comments 3 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
109
Forks
37
PR merge metrics
No merged PRs in 30d

Description

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
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> 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));
+ }
+
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.