Skip to content

Commit 470bcb5

Browse files
committed
Merge branch 'release/2.6.2'
2 parents ec170e7 + fe1dbd5 commit 470bcb5

20 files changed

Lines changed: 113 additions & 256 deletions

pom.xml

Lines changed: 4 additions & 4 deletions
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>2.6.1</version>
5+
<version>2.6.2</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>
@@ -18,8 +18,8 @@
1818
<maven.compiler.release>17</maven.compiler.release>
1919

2020
<!-- dependencies -->
21-
<cryptolib.version>2.1.0</cryptolib.version>
22-
<jwt.version>4.2.1</jwt.version>
21+
<cryptolib.version>2.1.2</cryptolib.version>
22+
<jwt.version>4.3.0</jwt.version>
2323
<dagger.version>2.44.2</dagger.version>
2424
<guava.version>31.1-jre</guava.version>
2525
<slf4j.version>2.0.3</slf4j.version>
@@ -30,7 +30,7 @@
3030
<hamcrest.version>2.2</hamcrest.version>
3131

3232
<!-- build plugin dependencies -->
33-
<dependency-check.version>7.3.2</dependency-check.version>
33+
<dependency-check.version>8.1.2</dependency-check.version>
3434
<jacoco.version>0.8.8</jacoco.version>
3535
<nexus-staging.version>1.6.13</nexus-staging.version>
3636
</properties>

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

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,13 @@ public interface CryptoFileSystemComponent {
1212

1313
CryptoFileSystemImpl cryptoFileSystem();
1414

15-
@Subcomponent.Builder
16-
interface Builder {
17-
18-
@BindsInstance
19-
Builder cryptor(Cryptor cryptor);
20-
21-
@BindsInstance
22-
Builder vaultConfig(VaultConfig vaultConfig);
23-
24-
@BindsInstance
25-
Builder provider(CryptoFileSystemProvider provider);
26-
27-
@BindsInstance
28-
Builder pathToVault(@PathToVault Path pathToVault);
29-
30-
@BindsInstance
31-
Builder properties(CryptoFileSystemProperties cryptoFileSystemProperties);
32-
33-
CryptoFileSystemComponent build();
15+
@Subcomponent.Factory
16+
interface Factory {
17+
CryptoFileSystemComponent create(@BindsInstance Cryptor cryptor, //
18+
@BindsInstance VaultConfig vaultConfig, //
19+
@BindsInstance CryptoFileSystemProvider provider, //
20+
@BindsInstance @PathToVault Path pathToVault, //
21+
@BindsInstance CryptoFileSystemProperties cryptoFileSystemProperties);
3422
}
3523

3624
}

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

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ class CryptoFileSystems {
3333
private static final Logger LOG = LoggerFactory.getLogger(CryptoFileSystems.class);
3434

3535
private final ConcurrentMap<Path, CryptoFileSystemImpl> fileSystems = new ConcurrentHashMap<>();
36-
private final CryptoFileSystemComponent.Builder cryptoFileSystemComponentBuilder; // sharing reusable builder via synchronized
36+
private final CryptoFileSystemComponent.Factory cryptoFileSystemComponentFactory;
3737
private final FileSystemCapabilityChecker capabilityChecker;
3838
private final SecureRandom csprng;
3939

4040
@Inject
41-
public CryptoFileSystems(CryptoFileSystemComponent.Builder cryptoFileSystemComponentBuilder, FileSystemCapabilityChecker capabilityChecker, SecureRandom csprng) {
42-
this.cryptoFileSystemComponentBuilder = cryptoFileSystemComponentBuilder;
41+
public CryptoFileSystems(CryptoFileSystemComponent.Factory cryptoFileSystemComponentFactory, FileSystemCapabilityChecker capabilityChecker, SecureRandom csprng) {
42+
this.cryptoFileSystemComponentFactory = cryptoFileSystemComponentFactory;
4343
this.capabilityChecker = capabilityChecker;
4444
this.csprng = csprng;
4545
}
@@ -59,7 +59,7 @@ public CryptoFileSystemImpl create(CryptoFileSystemProvider provider, Path pathT
5959
checkVaultRootExistence(pathToVault, cryptor);
6060
return fileSystems.compute(normalizedPathToVault, (path, fs) -> {
6161
if (fs == null) {
62-
return create(provider, normalizedPathToVault, adjustedProperties, cryptor, config);
62+
return cryptoFileSystemComponentFactory.create(cryptor, config, provider, normalizedPathToVault, adjustedProperties).cryptoFileSystem();
6363
} else {
6464
throw new FileSystemAlreadyExistsException();
6565
}
@@ -86,18 +86,6 @@ private void checkVaultRootExistence(Path pathToVault, Cryptor cryptor) throws C
8686
}
8787
}
8888

89-
// synchronized access to non-threadsafe cryptoFileSystemComponentBuilder required
90-
private synchronized CryptoFileSystemImpl create(CryptoFileSystemProvider provider, Path pathToVault, CryptoFileSystemProperties properties, Cryptor cryptor, VaultConfig config) {
91-
return cryptoFileSystemComponentBuilder //
92-
.cryptor(cryptor) //
93-
.vaultConfig(config) //
94-
.pathToVault(pathToVault) //
95-
.properties(properties) //
96-
.provider(provider) //
97-
.build() //
98-
.cryptoFileSystem();
99-
}
100-
10189
/**
10290
* Attempts to read a vault config file
10391
*

src/main/java/org/cryptomator/cryptofs/attr/AttributeComponent.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,12 @@ default <T extends BasicFileAttributes> T attributes(Class<T> type) {
2424
}
2525
}
2626

27-
@Subcomponent.Builder
28-
interface Builder {
27+
@Subcomponent.Factory
28+
interface Factory {
2929

30-
@BindsInstance
31-
Builder ciphertextPath(Path ciphertextPath);
30+
AttributeComponent create(@BindsInstance Path ciphertextPath, //
31+
@BindsInstance CiphertextFileType ciphertextFileType, //
32+
@BindsInstance @Named("ciphertext") BasicFileAttributes ciphertextAttributes);
3233

33-
@BindsInstance
34-
Builder ciphertextFileType(CiphertextFileType ciphertextFileType);
35-
36-
@BindsInstance
37-
Builder ciphertextAttributes(@Named("ciphertext") BasicFileAttributes ciphertextAttributes);
38-
39-
AttributeComponent build();
4034
}
4135
}

src/main/java/org/cryptomator/cryptofs/attr/AttributeProvider.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import org.cryptomator.cryptofs.common.CiphertextFileType;
1717

1818
import javax.inject.Inject;
19-
import javax.inject.Provider;
2019
import java.io.IOException;
2120
import java.nio.file.Files;
2221
import java.nio.file.LinkOption;
@@ -26,13 +25,13 @@
2625
@CryptoFileSystemScoped
2726
public class AttributeProvider {
2827

29-
private final Provider<AttributeComponent.Builder> attributeComponentBuilderProvider;
28+
private final AttributeComponent.Factory attributeComponentFactory;
3029
private final CryptoPathMapper pathMapper;
3130
private final Symlinks symlinks;
3231

3332
@Inject
34-
AttributeProvider(Provider<AttributeComponent.Builder> attributeComponentBuilderProvider, CryptoPathMapper pathMapper, Symlinks symlinks) {
35-
this.attributeComponentBuilderProvider = attributeComponentBuilderProvider;
33+
AttributeProvider(AttributeComponent.Factory attributeComponentFactory, CryptoPathMapper pathMapper, Symlinks symlinks) {
34+
this.attributeComponentFactory = attributeComponentFactory;
3635
this.pathMapper = pathMapper;
3736
this.symlinks = symlinks;
3837
}
@@ -45,13 +44,10 @@ public <A extends BasicFileAttributes> A readAttributes(CryptoPath cleartextPath
4544
}
4645
Path ciphertextPath = getCiphertextPath(cleartextPath, ciphertextFileType);
4746
A ciphertextAttrs = Files.readAttributes(ciphertextPath, type);
48-
AttributeComponent.Builder builder = attributeComponentBuilderProvider.get();
49-
return builder //
50-
.ciphertextFileType(ciphertextFileType) //
51-
.ciphertextPath(ciphertextPath) //
52-
.ciphertextAttributes(ciphertextAttrs) //
53-
.build() //
54-
.attributes(type);
47+
return attributeComponentFactory.create(ciphertextPath, //
48+
ciphertextFileType, //
49+
ciphertextAttrs) //
50+
.attributes(type); //
5551
}
5652

5753
private Path getCiphertextPath(CryptoPath path, CiphertextFileType type) throws IOException {

src/main/java/org/cryptomator/cryptofs/attr/AttributeViewComponent.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,11 @@ public interface AttributeViewComponent {
1414

1515
Optional<FileAttributeView> attributeView();
1616

17-
@Subcomponent.Builder
18-
interface Builder {
17+
@Subcomponent.Factory
18+
interface Factory {
1919

20-
@BindsInstance
21-
Builder cleartextPath(CryptoPath cleartextPath);
20+
AttributeViewComponent create(@BindsInstance CryptoPath cleartextPath, @BindsInstance Class<? extends FileAttributeView> type, @BindsInstance LinkOption[] linkOptions);
2221

23-
@BindsInstance
24-
Builder viewType(Class<? extends FileAttributeView> type);
25-
26-
@BindsInstance
27-
Builder linkOptions(LinkOption[] linkOptions);
28-
29-
AttributeViewComponent build();
3022
}
3123

3224
}

src/main/java/org/cryptomator/cryptofs/attr/AttributeViewProvider.java

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import org.slf4j.LoggerFactory;
1515

1616
import javax.inject.Inject;
17-
import javax.inject.Provider;
1817
import java.nio.file.Files;
1918
import java.nio.file.LinkOption;
2019
import java.nio.file.attribute.FileAttributeView;
@@ -25,27 +24,21 @@ public class AttributeViewProvider {
2524

2625
private static final Logger LOG = LoggerFactory.getLogger(AttributeViewProvider.class);
2726

28-
private final Provider<AttributeViewComponent.Builder> attrViewComponentBuilderProvider;
27+
private final AttributeViewComponent.Factory attrViewComponentFactory;
2928

3029
@Inject
31-
AttributeViewProvider(Provider<AttributeViewComponent.Builder> attrViewComponentBuilderProvider) {
32-
this.attrViewComponentBuilderProvider = attrViewComponentBuilderProvider;
30+
AttributeViewProvider(AttributeViewComponent.Factory attrViewComponentFactory) {
31+
this.attrViewComponentFactory = attrViewComponentFactory;
3332
}
3433

3534
/**
3635
* @param cleartextPath the unencrypted path to the file
37-
* @param type the Class object corresponding to the file attribute view
36+
* @param type the Class object corresponding to the file attribute view
3837
* @return a file attribute view of the specified type, or <code>null</code> if the attribute view type is not available
3938
* @see Files#getFileAttributeView(java.nio.file.Path, Class, java.nio.file.LinkOption...)
4039
*/
4140
public <A extends FileAttributeView> A getAttributeView(CryptoPath cleartextPath, Class<A> type, LinkOption... options) {
42-
AttributeViewComponent.Builder builder = attrViewComponentBuilderProvider.get();
43-
Optional<FileAttributeView> view = builder //
44-
.cleartextPath(cleartextPath) //
45-
.viewType(type) //
46-
.linkOptions(options) //
47-
.build() //
48-
.attributeView();
41+
Optional<FileAttributeView> view = attrViewComponentFactory.create(cleartextPath, type, options).attributeView();
4942
if (view.isPresent() && type.isInstance(view.get())) {
5043
return type.cast(view.get());
5144
} else {

src/main/java/org/cryptomator/cryptofs/ch/ChannelComponent.java

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,14 @@ public interface ChannelComponent {
1313

1414
CleartextFileChannel channel();
1515

16-
@Subcomponent.Builder
17-
interface Builder {
18-
19-
@BindsInstance
20-
Builder openOptions(EffectiveOpenOptions options);
21-
22-
@BindsInstance
23-
Builder onClose(ChannelCloseListener listener);
24-
25-
@BindsInstance
26-
Builder ciphertextChannel(FileChannel ciphertextChannel);
27-
28-
@BindsInstance
29-
Builder mustWriteHeader(@MustWriteHeader boolean mustWriteHeader);
30-
31-
@BindsInstance
32-
Builder fileHeader(FileHeader fileHeader);
33-
34-
ChannelComponent build();
16+
@Subcomponent.Factory
17+
interface Factory {
18+
19+
ChannelComponent create(@BindsInstance FileChannel ciphertextChannel, //
20+
@BindsInstance FileHeader fileHeader, //
21+
@BindsInstance @MustWriteHeader boolean mustWriteHeader, //
22+
@BindsInstance EffectiveOpenOptions options, //
23+
@BindsInstance ChannelCloseListener listener); //
3524
}
3625

3726
}

src/main/java/org/cryptomator/cryptofs/ch/CleartextFileChannel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ protected boolean isReadable() {
9393
}
9494

9595
@Override
96-
protected int readLocked(ByteBuffer dst, long position) throws IOException {
96+
protected synchronized int readLocked(ByteBuffer dst, long position) throws IOException {
9797
int origLimit = dst.limit();
9898
long limitConsideringEof = fileSize.get() - position;
9999
if (limitConsideringEof < 1) {

src/main/java/org/cryptomator/cryptofs/dir/DirectoryStreamComponent.java

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,14 @@ public interface DirectoryStreamComponent {
1414

1515
CryptoDirectoryStream directoryStream();
1616

17-
@Subcomponent.Builder
18-
interface Builder {
19-
20-
@BindsInstance
21-
Builder cleartextPath(@Named("cleartextPath") Path cleartextPath);
22-
23-
@BindsInstance
24-
Builder dirId(@Named("dirId") String dirId);
25-
26-
@BindsInstance
27-
Builder ciphertextDirectoryStream(DirectoryStream<Path> ciphertextDirectoryStream);
28-
29-
@BindsInstance
30-
Builder filter(DirectoryStream.Filter<? super Path> filter);
31-
32-
@BindsInstance
33-
Builder onClose(Consumer<CryptoDirectoryStream> onClose);
34-
35-
DirectoryStreamComponent build();
17+
@Subcomponent.Factory
18+
interface Factory {
19+
20+
DirectoryStreamComponent create(@BindsInstance @Named("cleartextPath") Path cleartextPath, //
21+
@BindsInstance @Named("dirId") String dirId, //
22+
@BindsInstance DirectoryStream<Path> ciphertextDirectoryStream, //
23+
@BindsInstance DirectoryStream.Filter<? super Path> filter, //
24+
@BindsInstance Consumer<CryptoDirectoryStream> onClose);
3625
}
3726

3827
}

0 commit comments

Comments
 (0)