Skip to content

Commit fffe0f4

Browse files
committed
Merge branch 'release/2.5.0'
2 parents b34eefd + 07aee13 commit fffe0f4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+563
-309
lines changed

.github/workflows/build.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ jobs:
77
runs-on: ubuntu-latest
88
if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')"
99
steps:
10-
- uses: actions/checkout@v2
10+
- uses: actions/checkout@v3
1111
with:
1212
fetch-depth: 0
13-
- uses: actions/setup-java@v2
13+
- uses: actions/setup-java@v3
1414
with:
1515
java-version: 17
1616
distribution: 'temurin'
1717
cache: 'maven'
1818
- name: Cache SonarCloud packages
19-
uses: actions/cache@v2
19+
uses: actions/cache@v3
2020
with:
2121
path: ~/.sonar/cache
2222
key: ${{ runner.os }}-sonar
@@ -36,12 +36,12 @@ jobs:
3636
env:
3737
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
3838
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
39-
- uses: actions/upload-artifact@v2
39+
- uses: actions/upload-artifact@v3
4040
with:
4141
name: artifacts
4242
path: target/*.jar
4343
- name: Create Release
44-
uses: actions/create-release@v1
44+
uses: actions/create-release@v1 #NOTE: action is archived and unmaintained
4545
if: startsWith(github.ref, 'refs/tags/')
4646
env:
4747
GITHUB_TOKEN: ${{ secrets.CRYPTOBOT_RELEASE_TOKEN }} # release as "cryptobot"

.github/workflows/codeql-analysis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@ jobs:
1515
runs-on: ubuntu-latest
1616
if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')"
1717
steps:
18-
- uses: actions/checkout@v2
18+
- uses: actions/checkout@v3
1919
with:
2020
fetch-depth: 2
21-
- uses: actions/setup-java@v2
21+
- uses: actions/setup-java@v3
2222
with:
2323
java-version: 17
2424
distribution: 'temurin'
2525
cache: 'maven'
2626
- name: Initialize CodeQL
27-
uses: github/codeql-action/init@v1
27+
uses: github/codeql-action/init@v2
2828
with:
2929
languages: java
3030
- name: Build and Test
3131
run: mvn -B install -DskipTests
3232
- name: Perform CodeQL Analysis
33-
uses: github/codeql-action/analyze@v1
33+
uses: github/codeql-action/analyze@v2

.github/workflows/publish-central.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ jobs:
1010
publish:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v2
13+
- uses: actions/checkout@v3
1414
with:
1515
ref: "refs/tags/${{ github.event.inputs.tag }}"
16-
- uses: actions/setup-java@v2
16+
- uses: actions/setup-java@v3
1717
with:
1818
java-version: 17
1919
distribution: 'temurin'

.github/workflows/publish-github.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ jobs:
77
runs-on: ubuntu-latest
88
if: startsWith(github.ref, 'refs/tags/') # only allow publishing tagged versions
99
steps:
10-
- uses: actions/checkout@v2
11-
- uses: actions/setup-java@v2
10+
- uses: actions/checkout@v3
11+
- uses: actions/setup-java@v3
1212
with:
1313
java-version: 17
1414
distribution: 'temurin'

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>2.4.5</version>
5+
<version>2.5.0</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: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,12 @@ void setAttribute(CryptoPath cleartextPath, String attribute, Object value, Link
230230
}
231231

232232
Map<String, Object> readAttributes(CryptoPath cleartextPath, String attributes, LinkOption... options) throws IOException {
233+
stats.incrementAccesses();
233234
return fileAttributeByNameProvider.readAttributes(cleartextPath, attributes, options);
234235
}
235236

236237
<A extends BasicFileAttributes> A readAttributes(CryptoPath cleartextPath, Class<A> type, LinkOption... options) throws IOException {
238+
stats.incrementAccesses();
237239
return fileAttributeProvider.readAttributes(cleartextPath, type, options);
238240
}
239241

@@ -387,6 +389,7 @@ private FileChannel newFileChannelFromFile(CryptoPath cleartextFilePath, Effecti
387389
if (options.readable()) {
388390
stats.incrementAccessesRead();
389391
}
392+
stats.incrementAccesses();
390393
return ch;
391394
} catch (Exception e) {
392395
ch.close();
@@ -669,4 +672,4 @@ public String toString() {
669672
return format("%sCryptoFileSystem(%s)", open ? "" : "closed ", pathToVault);
670673
}
671674

672-
}
675+
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public static void initialize(Path pathToVault, CryptoFileSystemProperties prope
143143
}
144144
byte[] rawKey = new byte[0];
145145
var config = VaultConfig.createNew().cipherCombo(properties.cipherCombo()).shorteningThreshold(properties.shorteningThreshold()).build();
146-
try (Masterkey key = properties.keyLoader().loadKey(keyId);
146+
try (Masterkey key = properties.keyLoader().loadKey(keyId); //
147147
Cryptor cryptor = CryptorProvider.forScheme(config.getCipherCombo()).provide(key, strongSecureRandom())) {
148148
rawKey = key.getEncoded();
149149
// save vault config:
@@ -154,6 +154,8 @@ public static void initialize(Path pathToVault, CryptoFileSystemProperties prope
154154
String dirHash = cryptor.fileNameCryptor().hashDirectoryId(Constants.ROOT_DIR_ID);
155155
Path vaultCipherRootPath = pathToVault.resolve(Constants.DATA_DIR_NAME).resolve(dirHash.substring(0, 2)).resolve(dirHash.substring(2));
156156
Files.createDirectories(vaultCipherRootPath);
157+
// create dirId backup:
158+
DirectoryIdBackup.backupManually(cryptor, new CryptoPathMapper.CiphertextDirectory(Constants.ROOT_DIR_ID, vaultCipherRootPath));
157159
} finally {
158160
Arrays.fill(rawKey, (byte) 0x00);
159161
}

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ public class CryptoFileSystemStats {
2727
private final LongAdder chunkCacheHits = new LongAdder();
2828
private final LongAdder amountOfAccessesRead = new LongAdder();
2929
private final LongAdder amountOfAccessesWritten = new LongAdder();
30+
private final LongAdder amountOfAccesses = new LongAdder();
31+
private final LongAdder totalAmountOfAccessed = new LongAdder();
3032

3133
@Inject
3234
CryptoFileSystemStats() {
@@ -122,4 +124,17 @@ public void incrementAccessesWritten() {
122124
amountOfAccessesWritten.increment();
123125
}
124126

127+
public long pollAmountOfAccesses() {
128+
return amountOfAccesses.sumThenReset();
129+
}
130+
131+
public long pollTotalAmountOfAccesses() {
132+
return totalAmountOfAccessed.sum();
133+
}
134+
135+
public void incrementAccesses() {
136+
totalAmountOfAccessed.increment();
137+
amountOfAccesses.increment();
138+
}
139+
125140
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ public CiphertextDirectory getCiphertextDir(CryptoPath cleartextPath) throws IOE
161161
} else {
162162
try {
163163
return ciphertextDirectories.get(cleartextPath, () -> {
164-
Path dirIdFile = getCiphertextFilePath(cleartextPath).getDirFilePath();
165-
return resolveDirectory(dirIdFile);
164+
Path dirFile = getCiphertextFilePath(cleartextPath).getDirFilePath();
165+
return resolveDirectory(dirFile);
166166
});
167167
} catch (ExecutionException e) {
168168
Throwables.throwIfInstanceOf(e.getCause(), IOException.class);

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import java.nio.file.StandardOpenOption;
1414

1515
/**
16-
* Single purpose class to backup the directory id of an encrypted directory when it is created.
16+
* Single purpose class to back up the directory id of an encrypted directory when it is created.
1717
*/
1818
@CryptoFileSystemScoped
1919
public class DirectoryIdBackup {
@@ -28,20 +28,20 @@ public DirectoryIdBackup(Cryptor cryptor) {
2828
/**
2929
* Performs the backup operation for the given {@link CryptoPathMapper.CiphertextDirectory} object.
3030
* <p>
31-
* The directory id is written via an encrypting channel to the file {@link CryptoPathMapper.CiphertextDirectory#path}/{@value Constants#DIR_ID_FILE}.
31+
* The directory id is written via an encrypting channel to the file {@link CryptoPathMapper.CiphertextDirectory#path}/{@value Constants#DIR_BACKUP_FILE_NAME}.
3232
*
3333
* @param ciphertextDirectory The cipher dir object containing the dir id and the encrypted content root
3434
* @throws IOException if an IOException is raised during the write operation
3535
*/
3636
public void execute(CryptoPathMapper.CiphertextDirectory ciphertextDirectory) throws IOException {
37-
try (var channel = Files.newByteChannel(ciphertextDirectory.path.resolve(Constants.DIR_ID_FILE), StandardOpenOption.CREATE_NEW, StandardOpenOption.WRITE); //
37+
try (var channel = Files.newByteChannel(ciphertextDirectory.path.resolve(Constants.DIR_BACKUP_FILE_NAME), StandardOpenOption.CREATE_NEW, StandardOpenOption.WRITE); //
3838
var encryptingChannel = wrapEncryptionAround(channel, cryptor)) {
3939
encryptingChannel.write(ByteBuffer.wrap(ciphertextDirectory.dirId.getBytes(StandardCharsets.US_ASCII)));
4040
}
4141
}
4242

4343
/**
44-
* Static method to explicitly backup the directory id for a specified ciphertext directory.
44+
* Static method to explicitly back up the directory id for a specified ciphertext directory.
4545
*
4646
* @param cryptor The cryptor to be used
4747
* @param ciphertextDirectory A {@link org.cryptomator.cryptofs.CryptoPathMapper.CiphertextDirectory} for which the dirId should be back up'd.

0 commit comments

Comments
 (0)