Skip to content
This repository was archived by the owner on Mar 14, 2025. It is now read-only.

Commit 32046dd

Browse files
committed
Merge branch 'release/1.0.0' into develop
2 parents 329e642 + c19c726 commit 32046dd

15 files changed

+208
-144
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<modelVersion>4.0.0</modelVersion>
66
<groupId>org.cryptomator</groupId>
77
<artifactId>cloud-access</artifactId>
8-
<version>1.0.0-SNAPSHOT</version>
8+
<version>1.1.0-SNAPSHOT</version>
99

1010
<name>Cryptomator CloudAccess in Java</name>
1111
<description>CloudAccess is used in e.g. Cryptomator for Android to access different cloud providers.</description>

src/main/java/org/cryptomator/cloudaccess/CloudAccess.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public static CloudProvider vaultFormat8GCMCloudAccess(CloudProvider cloudProvid
6060

6161
VaultFormat8ProviderDecorator provider = new VaultFormat8ProviderDecorator(cloudProvider, pathToVault.resolve("d"), cryptor);
6262
provider.initialize();
63-
return new MetadataCachingProviderDecorator(provider, Duration.ofSeconds(Long.getLong("org.cryptomator.cloudaccess.cryptometadatatimeout", 10L)));
63+
return new MetadataCachingProviderDecorator(provider);
6464
} catch (NoSuchAlgorithmException e) {
6565
throw new IllegalStateException("JVM doesn't supply a CSPRNG", e);
6666
} catch (InterruptedException e) {

src/main/java/org/cryptomator/cloudaccess/MetadataCachingProviderDecorator.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ public class MetadataCachingProviderDecorator implements CloudProvider {
2626
private final CloudProvider delegate;
2727

2828
public MetadataCachingProviderDecorator(CloudProvider delegate) {
29-
this(delegate, Duration.ofSeconds(DEFAULT_CACHE_TIMEOUT_SECONDS));
29+
this(delegate, Duration.ofSeconds( //
30+
Integer.getInteger("org.cryptomator.cloudaccess.metadatacachingprovider.timeoutSeconds", DEFAULT_CACHE_TIMEOUT_SECONDS)
31+
));
3032
}
3133

3234
public MetadataCachingProviderDecorator(CloudProvider delegate, Duration cacheEntryMaxAge) {

src/main/java/org/cryptomator/cloudaccess/api/CloudProvider.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ default CompletionStage<InputStream> read(CloudPath file, ProgressListener progr
130130
* <li>{@link org.cryptomator.cloudaccess.api.exceptions.NotFoundException} If the parent directory of this file doesn't exist</li>
131131
* <li>{@link org.cryptomator.cloudaccess.api.exceptions.TypeMismatchException} If the path points to a node that isn't a file</li>
132132
* <li>{@link org.cryptomator.cloudaccess.api.exceptions.AlreadyExistsException} If a node with the given path already exists and <code>replace</code> is false</li>
133+
* <li>{@link org.cryptomator.cloudaccess.api.exceptions.ParentFolderDoesNotExistException} If the parent folder of a node doesn't exists</li>
133134
* <li>{@link CloudProviderException} in case of generic I/O errors</li>
134135
* </ul>
135136
*
@@ -200,6 +201,7 @@ default CompletionStage<CloudPath> createFolderIfNonExisting(CloudPath folder) {
200201
* <ul>
201202
* <li>{@link org.cryptomator.cloudaccess.api.exceptions.NotFoundException} If no item exists for the given source path</li>
202203
* <li>{@link org.cryptomator.cloudaccess.api.exceptions.AlreadyExistsException} If a node with the given target path already exists and <code>replace</code> is false</li>
204+
* <li>{@link org.cryptomator.cloudaccess.api.exceptions.ParentFolderDoesNotExistException} If the parent folder of a node doesn't exists</li>
203205
* <li>{@link CloudProviderException} in case of generic I/O errors</li>
204206
* </ul>
205207
*

src/main/java/org/cryptomator/cloudaccess/api/NetworkTimeouts.java

Lines changed: 0 additions & 56 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package org.cryptomator.cloudaccess.api.exceptions;
2+
3+
public class ParentFolderDoesNotExistException extends CloudProviderException {
4+
}

src/main/java/org/cryptomator/cloudaccess/vaultformat8/FileHeaderCache.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@
1414

1515
class FileHeaderCache {
1616

17-
private static final Duration TIMEOUT = Duration.ofMillis(1000);
1817
private static final Logger LOG = LoggerFactory.getLogger(FileHeaderCache.class);
1918

20-
private final Cache<CloudPath, FileHeader> cache = CacheBuilder.newBuilder().expireAfterAccess(TIMEOUT).build();
19+
private final Cache<CloudPath, FileHeader> cache;
20+
21+
FileHeaderCache(int timeoutMillis) {
22+
this.cache = CacheBuilder.newBuilder().expireAfterAccess(Duration.ofMillis(timeoutMillis)).build();
23+
}
24+
2125

2226
public CompletionStage<FileHeader> get(CloudPath ciphertextPath, Function<CloudPath, CompletionStage<FileHeader>> onMiss) {
2327
var cached = cache.getIfPresent(ciphertextPath);
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package org.cryptomator.cloudaccess.vaultformat8;
2+
3+
public class VaultFormat8ProviderConfig {
4+
5+
private static final int DEFAULT_FILEHEADER_TIMEOUT = 1000;
6+
7+
private final int fileHeaderCacheTimeoutMillis;
8+
9+
private VaultFormat8ProviderConfig(){
10+
this.fileHeaderCacheTimeoutMillis = Integer.getInteger("org.cryptomator.cloudaccess.vaultformat8.fileheadertimeoutMillis", DEFAULT_FILEHEADER_TIMEOUT);
11+
}
12+
13+
public static VaultFormat8ProviderConfig createFromSystemProperties(){
14+
return new VaultFormat8ProviderConfig();
15+
}
16+
17+
int getFileHeaderCacheTimeoutMillis() {
18+
return fileHeaderCacheTimeoutMillis;
19+
}
20+
}

src/main/java/org/cryptomator/cloudaccess/vaultformat8/VaultFormat8ProviderDecorator.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,15 @@ public class VaultFormat8ProviderDecorator implements CloudProvider {
4747
private final Cryptor cryptor;
4848
private final DirectoryIdCache dirIdCache;
4949
private final FileHeaderCache fileHeaderCache;
50+
private final VaultFormat8ProviderConfig config;
5051

5152
public VaultFormat8ProviderDecorator(CloudProvider delegate, CloudPath dataDir, Cryptor cryptor) {
5253
this.delegate = delegate;
5354
this.dataDir = dataDir;
5455
this.cryptor = cryptor;
56+
this.config = VaultFormat8ProviderConfig.createFromSystemProperties();
5557
this.dirIdCache = new DirectoryIdCache();
56-
this.fileHeaderCache = new FileHeaderCache();
58+
this.fileHeaderCache = new FileHeaderCache(config.getFileHeaderCacheTimeoutMillis());
5759
}
5860

5961
public void initialize() throws InterruptedException, CloudProviderException {

0 commit comments

Comments
 (0)