Skip to content

Commit 62abbe0

Browse files
Merge tag '1.9.0' into develop
1.9.0
2 parents b40fe55 + d2144c3 commit 62abbe0

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>org.cryptomator</groupId>
44
<artifactId>cryptofs</artifactId>
5-
<version>1.9.0-SNAPSHOT</version>
5+
<version>1.10.0-SNAPSHOT</version>
66
<name>Cryptomator Crypto Filesystem</name>
77
<description>This library provides the Java filesystem provider used by Cryptomator.</description>
88
<url>https://github.com/cryptomator/cryptofs</url>

src/main/java/org/cryptomator/cryptofs/CryptoFileSystemImpl.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,14 @@
7171

7272
@CryptoFileSystemScoped
7373
class CryptoFileSystemImpl extends CryptoFileSystem {
74-
75-
private static final Logger LOG = LoggerFactory.getLogger(CryptoFileSystemImpl.class);
76-
74+
7775
private final CryptoFileSystemProvider provider;
7876
private final CryptoFileSystems cryptoFileSystems;
7977
private final Path pathToVault;
8078
private final Cryptor cryptor;
8179
private final CryptoFileStore fileStore;
8280
private final CryptoFileSystemStats stats;
8381
private final CryptoPathMapper cryptoPathMapper;
84-
private final LongFileNameProvider longFileNameProvider;
8582
private final CryptoPathFactory cryptoPathFactory;
8683
private final PathMatcherFactory pathMatcherFactory;
8784
private final DirectoryStreamFactory directoryStreamFactory;
@@ -102,7 +99,7 @@ class CryptoFileSystemImpl extends CryptoFileSystem {
10299

103100
@Inject
104101
public CryptoFileSystemImpl(CryptoFileSystemProvider provider, CryptoFileSystems cryptoFileSystems, @PathToVault Path pathToVault, Cryptor cryptor,
105-
CryptoFileStore fileStore, CryptoFileSystemStats stats, CryptoPathMapper cryptoPathMapper, LongFileNameProvider longFileNameProvider, CryptoPathFactory cryptoPathFactory,
102+
CryptoFileStore fileStore, CryptoFileSystemStats stats, CryptoPathMapper cryptoPathMapper, CryptoPathFactory cryptoPathFactory,
106103
PathMatcherFactory pathMatcherFactory, DirectoryStreamFactory directoryStreamFactory, DirectoryIdProvider dirIdProvider,
107104
AttributeProvider fileAttributeProvider, AttributeByNameProvider fileAttributeByNameProvider, AttributeViewProvider fileAttributeViewProvider,
108105
OpenCryptoFiles openCryptoFiles, Symlinks symlinks, FinallyUtil finallyUtil, CiphertextDirectoryDeleter ciphertextDirDeleter, ReadonlyFlag readonlyFlag, RootDirectoryInitializer rootDirectoryInitializer) {
@@ -113,7 +110,6 @@ public CryptoFileSystemImpl(CryptoFileSystemProvider provider, CryptoFileSystems
113110
this.fileStore = fileStore;
114111
this.stats = stats;
115112
this.cryptoPathMapper = cryptoPathMapper;
116-
this.longFileNameProvider = longFileNameProvider;
117113
this.cryptoPathFactory = cryptoPathFactory;
118114
this.pathMatcherFactory = pathMatcherFactory;
119115
this.directoryStreamFactory = directoryStreamFactory;

src/main/java/org/cryptomator/cryptofs/LongFileNameProvider.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@
2121
import java.nio.ByteBuffer;
2222
import java.nio.channels.SeekableByteChannel;
2323
import java.nio.channels.WritableByteChannel;
24+
import java.nio.file.FileAlreadyExistsException;
2425
import java.nio.file.Files;
2526
import java.nio.file.Path;
2627
import java.nio.file.StandardOpenOption;
2728
import java.time.Duration;
29+
import java.util.Arrays;
2830
import java.util.concurrent.ExecutionException;
2931

3032
import static java.nio.charset.StandardCharsets.UTF_8;
@@ -111,8 +113,11 @@ public void persist() {
111113
private void persistInternal() throws IOException {
112114
Path longNameFile = c9sPath.resolve(INFLATED_FILE_NAME);
113115
Files.createDirectories(c9sPath);
114-
try (WritableByteChannel ch = Files.newByteChannel(longNameFile, StandardOpenOption.WRITE, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING)) {
116+
try (WritableByteChannel ch = Files.newByteChannel(longNameFile, StandardOpenOption.WRITE, StandardOpenOption.CREATE_NEW)) {
115117
ch.write(UTF_8.encode(longName));
118+
} catch (FileAlreadyExistsException e) {
119+
// no-op: if the file already exists, we assume its content to be what we want (or we found a SHA1 collision ;-))
120+
assert Arrays.equals(Files.readAllBytes(longNameFile), longName.getBytes(UTF_8));
116121
}
117122
}
118123
}

src/test/java/org/cryptomator/cryptofs/CryptoFileSystemImplTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ public class CryptoFileSystemImplTest {
8888
private final OpenCryptoFiles openCryptoFiles = mock(OpenCryptoFiles.class);
8989
private final Symlinks symlinks = mock(Symlinks.class);
9090
private final CryptoPathMapper cryptoPathMapper = mock(CryptoPathMapper.class);
91-
private final LongFileNameProvider longFileNameProvider = Mockito.mock(LongFileNameProvider.class);
9291
private final DirectoryIdProvider dirIdProvider = mock(DirectoryIdProvider.class);
9392
private final AttributeProvider fileAttributeProvider = mock(AttributeProvider.class);
9493
private final AttributeByNameProvider fileAttributeByNameProvider = mock(AttributeByNameProvider.class);
@@ -113,7 +112,7 @@ public void setup() {
113112
when(cryptoPathFactory.emptyFor(any())).thenReturn(empty);
114113

115114
inTest = new CryptoFileSystemImpl(provider, cryptoFileSystems, pathToVault, cryptor,
116-
fileStore, stats, cryptoPathMapper, longFileNameProvider, cryptoPathFactory,
115+
fileStore, stats, cryptoPathMapper, cryptoPathFactory,
117116
pathMatcherFactory, directoryStreamFactory, dirIdProvider,
118117
fileAttributeProvider, fileAttributeByNameProvider, fileAttributeViewProvider,
119118
openCryptoFiles, symlinks, finallyUtil, ciphertextDirDeleter, readonlyFlag, rootDirectoryInitializer);

0 commit comments

Comments
 (0)