From ac02cbb46372dbc2ad659bb63d88dbc0202f09da Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Wed, 30 Oct 2019 17:35:41 +0100 Subject: [PATCH 1/4] bumped version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 658c5d5a..81093708 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 org.cryptomator cryptofs - 1.8.8 + 1.8.9 Cryptomator Crypto Filesystem This library provides the Java filesystem provider used by Cryptomator. https://github.com/cryptomator/cryptofs From 06685b09a0174a9022bcc38a1010eaf433b06b87 Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Wed, 30 Oct 2019 17:36:25 +0100 Subject: [PATCH 2/4] make better use of existing capabilities of Exception class --- .../cryptomator/cryptofs/fh/ExceptionsDuringWrite.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/cryptomator/cryptofs/fh/ExceptionsDuringWrite.java b/src/main/java/org/cryptomator/cryptofs/fh/ExceptionsDuringWrite.java index 9848394c..b1a057d5 100644 --- a/src/main/java/org/cryptomator/cryptofs/fh/ExceptionsDuringWrite.java +++ b/src/main/java/org/cryptomator/cryptofs/fh/ExceptionsDuringWrite.java @@ -14,20 +14,19 @@ @OpenFileScoped public class ExceptionsDuringWrite { - private final List 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; } } From eccecec004664f56edcc379b36ba12b8d399d7f0 Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Wed, 30 Oct 2019 17:36:37 +0100 Subject: [PATCH 3/4] fixes #67 --- .../cryptofs/ch/CleartextFileChannel.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/cryptomator/cryptofs/ch/CleartextFileChannel.java b/src/main/java/org/cryptomator/cryptofs/ch/CleartextFileChannel.java index af5d12f2..ccf205c6 100644 --- a/src/main/java/org/cryptomator/cryptofs/ch/CleartextFileChannel.java +++ b/src/main/java/org/cryptomator/cryptofs/ch/CleartextFileChannel.java @@ -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; @@ -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(); @@ -285,7 +293,7 @@ long beginOfChunk(long cleartextPos) { @Override protected void implCloseChannel() throws IOException { try { - forceInternal(true); + flush(); } finally { super.implCloseChannel(); closeListener.closed(this); From 8c069476f193d8534c67bef2cf753a5a4f00845d Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Wed, 30 Oct 2019 17:43:11 +0100 Subject: [PATCH 4/4] cherry picked dependency updates from dcc58cd --- pom.xml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pom.xml b/pom.xml index 81093708..ca51bb77 100644 --- a/pom.xml +++ b/pom.xml @@ -15,13 +15,13 @@ 1.2.1 - 2.22.1 - 27.1-jre - 1.7.26 + 2.24 + 28.1-jre + 1.7.28 - 5.4.2 - 2.27.0 - 2.1 + 5.5.2 + 3.1.0 + 2.2 UTF-8 @@ -129,7 +129,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.0 + 3.8.1 8 true @@ -145,7 +145,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.22.1 + 2.22.2 @@ -158,7 +158,7 @@ org.owasp dependency-check-maven - 4.0.2 + 5.2.2 24 0 @@ -185,7 +185,7 @@ org.jacoco jacoco-maven-plugin - 0.8.3 + 0.8.5 prepare-agent @@ -217,7 +217,7 @@ maven-source-plugin - 3.0.1 + 3.1.0 attach-sources @@ -229,7 +229,7 @@ maven-javadoc-plugin - 3.0.1 + 3.1.1 attach-javadocs