Skip to content

Commit

Permalink
Merge branch 'hotfix/1.8.9'
Browse files Browse the repository at this point in the history
  • Loading branch information
overheadhunter committed Oct 30, 2019
2 parents 66ad6fe + 8c06947 commit ea8356f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 24 deletions.
26 changes: 13 additions & 13 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>1.8.8</version>
<version>1.8.9</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 @@ -15,13 +15,13 @@

<properties>
<cryptolib.version>1.2.1</cryptolib.version>
<dagger.version>2.22.1</dagger.version>
<guava.version>27.1-jre</guava.version>
<slf4j.version>1.7.26</slf4j.version>
<dagger.version>2.24</dagger.version>
<guava.version>28.1-jre</guava.version>
<slf4j.version>1.7.28</slf4j.version>

<junit.jupiter.version>5.4.2</junit.jupiter.version>
<mockito.version>2.27.0</mockito.version>
<hamcrest.version>2.1</hamcrest.version>
<junit.jupiter.version>5.5.2</junit.jupiter.version>
<mockito.version>3.1.0</mockito.version>
<hamcrest.version>2.2</hamcrest.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Expand Down Expand Up @@ -129,7 +129,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<version>3.8.1</version>
<configuration>
<release>8</release>
<showWarnings>true</showWarnings>
Expand All @@ -145,7 +145,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<version>2.22.2</version>
</plugin>
</plugins>
</build>
Expand All @@ -158,7 +158,7 @@
<plugin>
<groupId>org.owasp</groupId>
<artifactId>dependency-check-maven</artifactId>
<version>4.0.2</version>
<version>5.2.2</version>
<configuration>
<cveValidForHours>24</cveValidForHours>
<failBuildOnCVSS>0</failBuildOnCVSS>
Expand All @@ -185,7 +185,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.3</version>
<version>0.8.5</version>
<executions>
<execution>
<id>prepare-agent</id>
Expand Down Expand Up @@ -217,7 +217,7 @@
<plugins>
<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<version>3.1.0</version>
<executions>
<execution>
<id>attach-sources</id>
Expand All @@ -229,7 +229,7 @@
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.1</version>
<version>3.1.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,7 @@ public void force(boolean metaData) throws IOException {
}

private void forceInternal(boolean metaData) throws IOException {
if (isWritable()) {
writeHeaderIfNeeded();
chunkCache.invalidateAll(); // TODO performance: write chunks but keep them cached
exceptionsDuringWrite.throwIfPresent();
}
flush();
ciphertextFileChannel.force(metaData);
if (metaData) {
FileTime lastModifiedTime = isWritable() ? FileTime.from(lastModified.get()) : null;
Expand All @@ -221,6 +217,18 @@ private void forceInternal(boolean metaData) throws IOException {
}
}

/**
* Writes in-memory contents to the ciphertext file
* @throws IOException
*/
private void flush() throws IOException {
if (isWritable()) {
writeHeaderIfNeeded();
chunkCache.invalidateAll(); // TODO performance: write chunks but keep them cached
exceptionsDuringWrite.throwIfPresent();
}
}

@Override
public MappedByteBuffer map(MapMode mode, long position, long size) {
throw new UnsupportedOperationException();
Expand Down Expand Up @@ -285,7 +293,7 @@ long beginOfChunk(long cleartextPos) {
@Override
protected void implCloseChannel() throws IOException {
try {
forceInternal(true);
flush();
} finally {
super.implCloseChannel();
closeListener.closed(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,19 @@
@OpenFileScoped
public class ExceptionsDuringWrite {

private final List<IOException> exceptions = new ArrayList<>();
private final IOException e = new IOException("Exceptions occured while writing");

@Inject
public ExceptionsDuringWrite() {
}

public synchronized void add(IOException e) {
exceptions.add(e);
e.addSuppressed(e);
}

public synchronized void throwIfPresent() throws IOException {
if (!exceptions.isEmpty()) {
IOException e = new IOException("Exceptions occured while writing");
exceptions.forEach(e::addSuppressed);
if (e.getSuppressed().length > 0) {
e.fillInStackTrace();
throw e;
}
}
Expand Down

0 comments on commit ea8356f

Please sign in to comment.