Skip to content

Commit

Permalink
Merge branch 'release/2.3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
infeo committed Dec 16, 2021
2 parents 6f92a4c + 2a8138c commit 0def366
Show file tree
Hide file tree
Showing 39 changed files with 428 additions and 190 deletions.
21 changes: 19 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,34 @@ jobs:
if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')"
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-java@v2
with:
java-version: 17
distribution: 'temurin'
cache: 'maven'
- name: Cache SonarCloud packages
uses: actions/cache@v2
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Ensure to use tagged version
if: startsWith(github.ref, 'refs/tags/')
run: mvn versions:set --file ./pom.xml -DnewVersion=${GITHUB_REF##*/}
- name: Build and Test
id: buildAndTest
run: mvn -B clean install jacoco:report -Pcoverage,dependency-check
run: >
mvn -B verify
jacoco:report
org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
-Pcoverage,dependency-check
-Dsonar.projectKey=cryptomator_cryptofs
-Dsonar.organization=cryptomator
-Dsonar.host.url=https://sonarcloud.io
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: Upload code coverage report
id: codacyCoverageReporter
run: bash <(curl -Ls https://coverage.codacy.com/get.sh)
Expand Down
7 changes: 5 additions & 2 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.3.0</version>
<version>2.3.1</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 Down Expand Up @@ -33,6 +33,9 @@
<dependency-check.version>6.2.2</dependency-check.version>
<jacoco.version>0.8.7</jacoco.version>
<nexus-staging.version>1.6.8</nexus-staging.version>

<!-- empty default needed to not break testing due to maven-surefire-plugin config -->
<argLine></argLine>
</properties>

<licenses>
Expand Down Expand Up @@ -143,7 +146,7 @@
<version>3.0.0-M5</version>
<configuration>
<!-- Allow reflection for Mockito, so it can properly mock non-public classes -->
<argLine>--add-opens=org.cryptomator.cryptofs/org.cryptomator.cryptofs.health.dirid=ALL-UNNAMED
<argLine>${argLine} --add-opens=org.cryptomator.cryptofs/org.cryptomator.cryptofs.health.dirid=ALL-UNNAMED
--add-opens=org.cryptomator.cryptofs/org.cryptomator.cryptofs.health.type=ALL-UNNAMED
--add-opens=org.cryptomator.cryptofs/org.cryptomator.cryptofs.health.shortened=ALL-UNNAMED</argLine>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
package org.cryptomator.cryptofs;

import dagger.Module;
import dagger.Provides;

import javax.inject.Singleton;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;

@Module(subcomponents = {CryptoFileSystemComponent.class})
public class CryptoFileSystemProviderModule {
Expand Down
17 changes: 14 additions & 3 deletions src/main/java/org/cryptomator/cryptofs/CryptoPath.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Objects;

import static org.cryptomator.cryptofs.common.Constants.SEPARATOR;
Expand Down Expand Up @@ -125,7 +126,13 @@ public CryptoPath getName(int index) {
@Override
public CryptoPath subpath(int beginIndex, int endIndex) {
fileSystem.assertOpen();
return new CryptoPath(fileSystem, symlinks, elements.subList(beginIndex, endIndex), false);
final List<String> sublist;
try {
sublist = elements.subList(beginIndex, endIndex);
} catch (IndexOutOfBoundsException e) {
throw new IllegalArgumentException(e);
}
return new CryptoPath(fileSystem, symlinks, sublist, false);
}

@Override
Expand Down Expand Up @@ -308,7 +315,7 @@ public WatchKey register(WatchService watcher, WatchEvent.Kind<?>... events) thr
@Override
public Iterator<Path> iterator() {
fileSystem.assertOpen();
return new Iterator<Path>() {
return new Iterator<>() {

private int idx = 0;

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

@Override
public Path next() {
return getName(idx++);
try {
return getName(idx++);
} catch (IllegalArgumentException e) {
throw new NoSuchElementException(e);
}
}
};
}
Expand Down
10 changes: 4 additions & 6 deletions src/main/java/org/cryptomator/cryptofs/CryptoPathFactory.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
package org.cryptomator.cryptofs;

import com.google.common.base.Splitter;

import javax.inject.Inject;
import java.text.Normalizer;
import java.util.Collections;
import java.util.stream.Stream;

import javax.inject.Inject;

import com.google.common.base.Splitter;

import static java.util.Arrays.stream;
import static java.util.Spliterator.IMMUTABLE;
import static java.util.Spliterator.NONNULL;
import static java.util.Spliterator.ORDERED;
import static java.util.Spliterators.spliteratorUnknownSize;
import static java.util.stream.Collectors.toList;
import static java.util.stream.StreamSupport.stream;
import static org.cryptomator.cryptofs.common.Constants.SEPARATOR;

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

public CryptoPath emptyFor(CryptoFileSystemImpl fileSystem) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,10 @@
import java.io.UncheckedIOException;
import java.nio.ByteBuffer;
import java.nio.channels.SeekableByteChannel;
import java.nio.channels.WritableByteChannel;
import java.nio.file.FileAlreadyExistsException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.time.Duration;
import java.util.Arrays;
import java.util.concurrent.ExecutionException;

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

Expand Down
4 changes: 0 additions & 4 deletions src/main/java/org/cryptomator/cryptofs/ReadonlyFlag.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
import org.slf4j.LoggerFactory;

import javax.inject.Inject;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.ReadOnlyFileSystemException;

@CryptoFileSystemScoped
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ abstract sealed class AbstractCryptoFileAttributeView implements FileAttributeVi
private final Symlinks symlinks;
private final OpenCryptoFiles openCryptoFiles;

public AbstractCryptoFileAttributeView(CryptoPath cleartextPath, CryptoPathMapper pathMapper, LinkOption[] linkOptions, Symlinks symlinks, OpenCryptoFiles openCryptoFiles) {
protected AbstractCryptoFileAttributeView(CryptoPath cleartextPath, CryptoPathMapper pathMapper, LinkOption[] linkOptions, Symlinks symlinks, OpenCryptoFiles openCryptoFiles) {
this.cleartextPath = cleartextPath;
this.pathMapper = pathMapper;
this.linkOptions = linkOptions;
Expand Down
Loading

0 comments on commit 0def366

Please sign in to comment.