Skip to content

Commit e2edee0

Browse files
Merge branch 'release/1.8.4'
2 parents 20e00a0 + 48bdfb5 commit e2edee0

File tree

6 files changed

+271
-224
lines changed

6 files changed

+271
-224
lines changed

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>1.8.3</version>
5+
<version>1.8.4</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/attr/CryptoBasicFileAttributes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ private static long calculatePlaintextFileSize(Path ciphertextPath, long size, C
6161
try {
6262
return Cryptors.cleartextSize(size - cryptor.fileHeaderCryptor().headerSize(), cryptor);
6363
} catch (IllegalArgumentException e) {
64-
LOG.warn("Unable to calculate cleartext file size for " + ciphertextPath + ".", e);
64+
LOG.warn("Unable to calculate cleartext file size for {}. Ciphertext size (including header): {}", ciphertextPath, size);
6565
return 0l;
6666
}
6767
}

src/main/java/org/cryptomator/cryptofs/ch/CleartextFileChannel.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@ public CleartextFileChannel(FileChannel ciphertextFileChannel, FileHeaderLoader
6969
if (options.append()) {
7070
position = fileSize.get();
7171
}
72-
headerWritten = !options.writable();
72+
this.headerWritten = !options.writable();
73+
if (options.createNew() || options.create()) {
74+
lastModified.compareAndSet(Instant.EPOCH, Instant.now());
75+
}
7376
}
7477

7578
@Override
@@ -163,6 +166,9 @@ private long writeLockedInternal(ByteSource src, long position) throws IOExcepti
163166
long newSize = fileSize.updateAndGet(size -> max(minSize, size));
164167
assert newSize >= minSize;
165168
lastModified.set(Instant.now());
169+
if (options.syncData()) {
170+
forceInternal(options.syncDataAndMetadata());
171+
}
166172
stats.addBytesWritten(written);
167173
return written;
168174
}
@@ -205,9 +211,13 @@ private void forceInternal(boolean metaData) throws IOException {
205211
writeHeaderIfNeeded();
206212
chunkCache.invalidateAll(); // TODO performance: write chunks but keep them cached
207213
exceptionsDuringWrite.throwIfPresent();
208-
attrViewProvider.get().setTimes(FileTime.from(lastModified.get()), null, null);
209214
}
210215
ciphertextFileChannel.force(metaData);
216+
if (metaData) {
217+
FileTime lastModifiedTime = isWritable() ? FileTime.from(lastModified.get()) : null;
218+
FileTime lastAccessTime = FileTime.from(Instant.now());
219+
attrViewProvider.get().setTimes(lastModifiedTime, lastAccessTime, null);
220+
}
211221
}
212222

213223
@Override

src/main/java/org/cryptomator/cryptofs/fh/OpenCryptoFileModule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public Supplier<BasicFileAttributeView> provideBasicFileAttributeViewSupplier(@C
4949
@OpenFileScoped
5050
@OpenFileModifiedDate
5151
public AtomicReference<Instant> provideLastModifiedDate(@OriginalOpenFilePath Path originalPath) {
52-
Instant lastModifiedDate = readBasicAttributes(originalPath).map(BasicFileAttributes::lastModifiedTime).map(FileTime::toInstant).orElse(Instant.ofEpochMilli(0));
52+
Instant lastModifiedDate = readBasicAttributes(originalPath).map(BasicFileAttributes::lastModifiedTime).map(FileTime::toInstant).orElse(Instant.EPOCH);
5353
return new AtomicReference<>(lastModifiedDate);
5454
}
5555

0 commit comments

Comments
 (0)