Skip to content

Commit

Permalink
Merge branch 'release/2.6.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
infeo committed Nov 28, 2023
2 parents ae15463 + a37c26b commit 6f04f2a
Show file tree
Hide file tree
Showing 12 changed files with 179 additions and 70 deletions.
44 changes: 44 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
version: 2
updates:
- package-ecosystem: "maven"
directory: "/"
schedule:
interval: "weekly"
day: "monday"
time: "06:00"
timezone: "UTC"
groups:
java-test-dependencies:
patterns:
- "org.junit.jupiter:*"
- "org.mockito:*"
- "org.hamcrest:*"
- "com.google.jimfs:jimfs"
maven-build-plugins:
patterns:
- "org.apache.maven.plugins:*"
- "org.jacoco:jacoco-maven-plugin"
- "org.owasp:dependency-check-maven"
java-production-dependencies:
patterns:
- "*"
exclude-patterns:
- "org.apache.maven.plugins:*"
- "org.jacoco:jacoco-maven-plugin"
- "org.owasp:dependency-check-maven"
- "org.junit.jupiter:*"
- "org.mockito:*"
- "org.hamcrest:*"
- "com.google.jimfs:jimfs"


- package-ecosystem: "github-actions"
directory: "/" # even for `.github/workflows`
schedule:
interval: "monthly"
groups:
github-actions:
patterns:
- "*"
labels:
- "ci"
16 changes: 7 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ jobs:
build:
name: Build and Test
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')"
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
show-progress: false
- uses: actions/setup-java@v3
with:
java-version: 17
Expand All @@ -29,7 +29,7 @@ jobs:
mvn -B verify
jacoco:report
org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
-Pcoverage,dependency-check
-Pcoverage
-Dsonar.projectKey=cryptomator_cryptofs
-Dsonar.organization=cryptomator
-Dsonar.host.url=https://sonarcloud.io
Expand All @@ -40,12 +40,10 @@ jobs:
with:
name: artifacts
path: target/*.jar
- name: Create Release
uses: actions/create-release@v1 #NOTE: action is archived and unmaintained
- name: Create release
if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.CRYPTOBOT_RELEASE_TOKEN }} # release as "cryptobot"
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
token: ${{ secrets.CRYPTOBOT_RELEASE_TOKEN }}
generate_release_notes: true
prerelease: true
8 changes: 5 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ jobs:
analyse:
name: Analyse
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')"
# dependeabot has on push events only read-only access, but codeql requires write access
if: ${{ !(github.actor == 'dependabot[bot]' && contains(fromJSON('["push"]'), github.event_name)) }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 2
show-progress: false
- uses: actions/setup-java@v3
with:
java-version: 17
Expand All @@ -27,7 +29,7 @@ jobs:
uses: github/codeql-action/init@v2
with:
languages: java
- name: Build and Test
- name: Build
run: mvn -B install -DskipTests
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
3 changes: 2 additions & 1 deletion .github/workflows/publish-central.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: "refs/tags/${{ github.event.inputs.tag }}"
show-progress: false
- uses: actions/setup-java@v3
with:
java-version: 17
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/publish-github.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ jobs:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/') # only allow publishing tagged versions
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
show-progress: false
- uses: actions/setup-java@v3
with:
java-version: 17
Expand Down
1 change: 1 addition & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 30 additions & 15 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.cryptomator</groupId>
<artifactId>cryptofs</artifactId>
<version>2.6.7</version>
<version>2.6.8</version>
<name>Cryptomator Crypto Filesystem</name>
<description>This library provides the Java filesystem provider used by Cryptomator.</description>
<url>https://github.com/cryptomator/cryptofs</url>
Expand All @@ -20,19 +20,21 @@
<!-- dependencies -->
<cryptolib.version>2.1.2</cryptolib.version>
<jwt.version>4.4.0</jwt.version>
<dagger.version>2.44.2</dagger.version>
<guava.version>32.0.0-jre</guava.version>
<caffeine.version>3.1.4</caffeine.version>
<slf4j.version>2.0.3</slf4j.version>
<dagger.version>2.48.1</dagger.version>
<guava.version>32.1.3-jre</guava.version>
<caffeine.version>3.1.8</caffeine.version>
<slf4j.version>2.0.9</slf4j.version>

<!-- test dependencies -->
<junit.jupiter.version>5.9.1</junit.jupiter.version>
<mockito.version>4.9.0</mockito.version>
<junit.jupiter.version>5.10.1</junit.jupiter.version>
<mockito.version>5.2.0</mockito.version>
<hamcrest.version>2.2</hamcrest.version>
<jimfs.version>1.3.0</jimfs.version>

<!-- build plugin dependencies -->
<dependency-check.version>8.1.2</dependency-check.version>
<jacoco.version>0.8.8</jacoco.version>
<dependency-check.version>9.0.1</dependency-check.version>
<junit-tree-reporter.version>1.2.1</junit-tree-reporter.version>
<jacoco.version>0.8.11</jacoco.version>
<nexus-staging.version>1.6.13</nexus-staging.version>
</properties>

Expand Down Expand Up @@ -131,7 +133,7 @@
<dependency>
<groupId>com.google.jimfs</groupId>
<artifactId>jimfs</artifactId>
<version>1.2</version>
<version>${jimfs.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand All @@ -141,7 +143,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<version>3.11.0</version>
<configuration>
<showWarnings>true</showWarnings>
<annotationProcessorPaths>
Expand All @@ -156,11 +158,24 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M7</version>
<version>3.2.2</version>
<dependencies>
<dependency>
<groupId>me.fabriciorby</groupId>
<artifactId>maven-surefire-junit5-tree-reporter</artifactId>
<version>${junit-tree-reporter.version}</version>
</dependency>
</dependencies>
<configuration>
<systemPropertyVariables>
<org.slf4j.simpleLogger.defaultLogLevel>ERROR</org.slf4j.simpleLogger.defaultLogLevel>
</systemPropertyVariables>
<consoleOutputReporter>
<disable>true</disable>
</consoleOutputReporter>
<statelessTestsetInfoReporter
implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5StatelessTestsetInfoTreeReporter">
</statelessTestsetInfoReporter>
</configuration>
</plugin>
<plugin>
Expand All @@ -170,7 +185,7 @@
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
<version>3.3.0</version>
<executions>
<execution>
<id>attach-sources</id>
Expand All @@ -182,7 +197,7 @@
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.4.1</version>
<version>3.6.2</version>
<executions>
<execution>
<id>attach-javadocs</id>
Expand Down Expand Up @@ -283,7 +298,7 @@
<plugins>
<plugin>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.0.1</version>
<version>3.1.0</version>
<executions>
<execution>
<id>sign-artifacts</id>
Expand Down
37 changes: 17 additions & 20 deletions src/main/java/org/cryptomator/cryptofs/CryptoPathMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*******************************************************************************/
package org.cryptomator.cryptofs;

import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.AsyncCache;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.github.benmanes.caffeine.cache.LoadingCache;
import com.google.common.io.BaseEncoding;
Expand All @@ -20,7 +20,6 @@

import javax.inject.Inject;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.FileAlreadyExistsException;
import java.nio.file.Files;
Expand All @@ -31,6 +30,7 @@
import java.time.Duration;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;

import static org.cryptomator.cryptofs.common.Constants.DATA_DIR_NAME;

Expand All @@ -48,7 +48,7 @@ public class CryptoPathMapper {
private final LongFileNameProvider longFileNameProvider;
private final VaultConfig vaultConfig;
private final LoadingCache<DirIdAndName, String> ciphertextNames;
private final Cache<CryptoPath, CiphertextDirectory> ciphertextDirectories;
private final AsyncCache<CryptoPath, CiphertextDirectory> ciphertextDirectories;

private final CiphertextDirectory rootDirectory;

Expand All @@ -60,7 +60,7 @@ public class CryptoPathMapper {
this.longFileNameProvider = longFileNameProvider;
this.vaultConfig = vaultConfig;
this.ciphertextNames = Caffeine.newBuilder().maximumSize(MAX_CACHED_CIPHERTEXT_NAMES).build(this::getCiphertextFileName);
this.ciphertextDirectories = Caffeine.newBuilder().maximumSize(MAX_CACHED_DIR_PATHS).expireAfterWrite(MAX_CACHE_AGE).build();
this.ciphertextDirectories = Caffeine.newBuilder().maximumSize(MAX_CACHED_DIR_PATHS).expireAfterWrite(MAX_CACHE_AGE).buildAsync();
this.rootDirectory = resolveDirectory(Constants.ROOT_DIR_ID);
}

Expand Down Expand Up @@ -123,7 +123,7 @@ public CiphertextFilePath getCiphertextFilePath(CryptoPath cleartextPath) throws
String cleartextName = cleartextPath.getFileName().toString();
return getCiphertextFilePath(parent.path, parent.dirId, cleartextName);
}

public CiphertextFilePath getCiphertextFilePath(Path parentCiphertextDir, String parentDirId, String cleartextName) {
String ciphertextName = ciphertextNames.get(new DirIdAndName(parentDirId, cleartextName));
Path c9rPath = parentCiphertextDir.resolve(ciphertextName);
Expand All @@ -140,14 +140,13 @@ private String getCiphertextFileName(DirIdAndName dirIdAndName) {
}

public void invalidatePathMapping(CryptoPath cleartextPath) {
ciphertextDirectories.invalidate(cleartextPath);
ciphertextDirectories.asMap().remove(cleartextPath);
}

public void movePathMapping(CryptoPath cleartextSrc, CryptoPath cleartextDst) {
CiphertextDirectory cachedValue = ciphertextDirectories.getIfPresent(cleartextSrc);
var cachedValue = ciphertextDirectories.asMap().remove(cleartextSrc);
if (cachedValue != null) {
ciphertextDirectories.put(cleartextDst, cachedValue);
ciphertextDirectories.invalidate(cleartextSrc);
}
}

Expand All @@ -157,17 +156,15 @@ public CiphertextDirectory getCiphertextDir(CryptoPath cleartextPath) throws IOE
if (parentPath == null) {
return rootDirectory;
} else {
try {
return ciphertextDirectories.get(cleartextPath, p -> {
try {
Path dirFile = getCiphertextFilePath(p).getDirFilePath();
return resolveDirectory(dirFile);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
});
} catch (UncheckedIOException e) {
throw new IOException(e);
var lazyEntry = new CompletableFuture<CiphertextDirectory>();
var priorEntry = ciphertextDirectories.asMap().putIfAbsent(cleartextPath, lazyEntry);
if (priorEntry != null) {
return priorEntry.join();
} else {
Path dirFile = getCiphertextFilePath(cleartextPath).getDirFilePath();
CiphertextDirectory cipherDir = resolveDirectory(dirFile);
lazyEntry.complete(cipherDir);
return cipherDir;
}
}
}
Expand Down
Loading

0 comments on commit 6f04f2a

Please sign in to comment.