Skip to content

Commit 0def366

Browse files
committed
Merge branch 'release/2.3.1'
2 parents 6f92a4c + 2a8138c commit 0def366

39 files changed

+428
-190
lines changed

.github/workflows/build.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,34 @@ jobs:
88
if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')"
99
steps:
1010
- uses: actions/checkout@v2
11+
with:
12+
fetch-depth: 0
1113
- uses: actions/setup-java@v2
1214
with:
1315
java-version: 17
1416
distribution: 'temurin'
1517
cache: 'maven'
18+
- name: Cache SonarCloud packages
19+
uses: actions/cache@v2
20+
with:
21+
path: ~/.sonar/cache
22+
key: ${{ runner.os }}-sonar
23+
restore-keys: ${{ runner.os }}-sonar
1624
- name: Ensure to use tagged version
1725
if: startsWith(github.ref, 'refs/tags/')
1826
run: mvn versions:set --file ./pom.xml -DnewVersion=${GITHUB_REF##*/}
1927
- name: Build and Test
20-
id: buildAndTest
21-
run: mvn -B clean install jacoco:report -Pcoverage,dependency-check
28+
run: >
29+
mvn -B verify
30+
jacoco:report
31+
org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
32+
-Pcoverage,dependency-check
33+
-Dsonar.projectKey=cryptomator_cryptofs
34+
-Dsonar.organization=cryptomator
35+
-Dsonar.host.url=https://sonarcloud.io
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
38+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
2239
- name: Upload code coverage report
2340
id: codacyCoverageReporter
2441
run: bash <(curl -Ls https://coverage.codacy.com/get.sh)

pom.xml

Lines changed: 5 additions & 2 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.3.0</version>
5+
<version>2.3.1</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>
@@ -33,6 +33,9 @@
3333
<dependency-check.version>6.2.2</dependency-check.version>
3434
<jacoco.version>0.8.7</jacoco.version>
3535
<nexus-staging.version>1.6.8</nexus-staging.version>
36+
37+
<!-- empty default needed to not break testing due to maven-surefire-plugin config -->
38+
<argLine></argLine>
3639
</properties>
3740

3841
<licenses>
@@ -143,7 +146,7 @@
143146
<version>3.0.0-M5</version>
144147
<configuration>
145148
<!-- Allow reflection for Mockito, so it can properly mock non-public classes -->
146-
<argLine>--add-opens=org.cryptomator.cryptofs/org.cryptomator.cryptofs.health.dirid=ALL-UNNAMED
149+
<argLine>${argLine} --add-opens=org.cryptomator.cryptofs/org.cryptomator.cryptofs.health.dirid=ALL-UNNAMED
147150
--add-opens=org.cryptomator.cryptofs/org.cryptomator.cryptofs.health.type=ALL-UNNAMED
148151
--add-opens=org.cryptomator.cryptofs/org.cryptomator.cryptofs.health.shortened=ALL-UNNAMED</argLine>
149152
</configuration>

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
package org.cryptomator.cryptofs;
22

33
import dagger.Module;
4-
import dagger.Provides;
5-
6-
import javax.inject.Singleton;
7-
import java.security.NoSuchAlgorithmException;
8-
import java.security.SecureRandom;
94

105
@Module(subcomponents = {CryptoFileSystemComponent.class})
116
public class CryptoFileSystemProviderModule {

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.util.Iterator;
2525
import java.util.LinkedList;
2626
import java.util.List;
27+
import java.util.NoSuchElementException;
2728
import java.util.Objects;
2829

2930
import static org.cryptomator.cryptofs.common.Constants.SEPARATOR;
@@ -125,7 +126,13 @@ public CryptoPath getName(int index) {
125126
@Override
126127
public CryptoPath subpath(int beginIndex, int endIndex) {
127128
fileSystem.assertOpen();
128-
return new CryptoPath(fileSystem, symlinks, elements.subList(beginIndex, endIndex), false);
129+
final List<String> sublist;
130+
try {
131+
sublist = elements.subList(beginIndex, endIndex);
132+
} catch (IndexOutOfBoundsException e) {
133+
throw new IllegalArgumentException(e);
134+
}
135+
return new CryptoPath(fileSystem, symlinks, sublist, false);
129136
}
130137

131138
@Override
@@ -308,7 +315,7 @@ public WatchKey register(WatchService watcher, WatchEvent.Kind<?>... events) thr
308315
@Override
309316
public Iterator<Path> iterator() {
310317
fileSystem.assertOpen();
311-
return new Iterator<Path>() {
318+
return new Iterator<>() {
312319

313320
private int idx = 0;
314321

@@ -319,7 +326,11 @@ public boolean hasNext() {
319326

320327
@Override
321328
public Path next() {
322-
return getName(idx++);
329+
try {
330+
return getName(idx++);
331+
} catch (IllegalArgumentException e) {
332+
throw new NoSuchElementException(e);
333+
}
323334
}
324335
};
325336
}

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
package org.cryptomator.cryptofs;
22

3+
import com.google.common.base.Splitter;
4+
5+
import javax.inject.Inject;
36
import java.text.Normalizer;
47
import java.util.Collections;
58
import java.util.stream.Stream;
69

7-
import javax.inject.Inject;
8-
9-
import com.google.common.base.Splitter;
10-
1110
import static java.util.Arrays.stream;
1211
import static java.util.Spliterator.IMMUTABLE;
1312
import static java.util.Spliterator.NONNULL;
1413
import static java.util.Spliterator.ORDERED;
1514
import static java.util.Spliterators.spliteratorUnknownSize;
16-
import static java.util.stream.Collectors.toList;
1715
import static java.util.stream.StreamSupport.stream;
1816
import static org.cryptomator.cryptofs.common.Constants.SEPARATOR;
1917

@@ -30,7 +28,7 @@ public CryptoPathFactory(Symlinks symlinks) {
3028
public CryptoPath getPath(CryptoFileSystemImpl fileSystem, String first, String... more) {
3129
boolean isAbsolute = first.startsWith(SEPARATOR);
3230
Stream<String> elements = Stream.concat(Stream.of(first), stream(more)).flatMap(this::splitPath).map(this::normalize);
33-
return new CryptoPath(fileSystem, symlinks, elements.collect(toList()), isAbsolute);
31+
return new CryptoPath(fileSystem, symlinks, elements.toList(), isAbsolute);
3432
}
3533

3634
public CryptoPath emptyFor(CryptoFileSystemImpl fileSystem) {

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,10 @@
2020
import java.io.UncheckedIOException;
2121
import java.nio.ByteBuffer;
2222
import java.nio.channels.SeekableByteChannel;
23-
import java.nio.channels.WritableByteChannel;
24-
import java.nio.file.FileAlreadyExistsException;
2523
import java.nio.file.Files;
2624
import java.nio.file.Path;
2725
import java.nio.file.StandardOpenOption;
2826
import java.time.Duration;
29-
import java.util.Arrays;
3027
import java.util.concurrent.ExecutionException;
3128

3229
import static java.nio.charset.StandardCharsets.UTF_8;
@@ -116,7 +113,7 @@ public void persist() {
116113
private void persistInternal() throws IOException {
117114
Path longNameFile = c9sPath.resolve(INFLATED_FILE_NAME);
118115
Files.createDirectories(c9sPath);
119-
Files.write(longNameFile,UTF_8.encode(longName).array()); //WRITE, CREATE, TRUNCATE_EXISTING
116+
Files.writeString(longNameFile, longName, UTF_8, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE, StandardOpenOption.CREATE);
120117
}
121118
}
122119

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
import org.slf4j.LoggerFactory;
55

66
import javax.inject.Inject;
7-
import java.io.IOException;
8-
import java.io.UncheckedIOException;
9-
import java.nio.file.Files;
10-
import java.nio.file.Path;
117
import java.nio.file.ReadOnlyFileSystemException;
128

139
@CryptoFileSystemScoped

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ abstract sealed class AbstractCryptoFileAttributeView implements FileAttributeVi
3131
private final Symlinks symlinks;
3232
private final OpenCryptoFiles openCryptoFiles;
3333

34-
public AbstractCryptoFileAttributeView(CryptoPath cleartextPath, CryptoPathMapper pathMapper, LinkOption[] linkOptions, Symlinks symlinks, OpenCryptoFiles openCryptoFiles) {
34+
protected AbstractCryptoFileAttributeView(CryptoPath cleartextPath, CryptoPathMapper pathMapper, LinkOption[] linkOptions, Symlinks symlinks, OpenCryptoFiles openCryptoFiles) {
3535
this.cleartextPath = cleartextPath;
3636
this.pathMapper = pathMapper;
3737
this.linkOptions = linkOptions;

0 commit comments

Comments
 (0)