Skip to content

Commit

Permalink
Merge branch 'release/1.8.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
overheadhunter committed May 16, 2019
2 parents 20e00a0 + 48bdfb5 commit e2edee0
Show file tree
Hide file tree
Showing 6 changed files with 271 additions and 224 deletions.
2 changes: 1 addition & 1 deletion 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.3</version>
<version>1.8.4</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
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private static long calculatePlaintextFileSize(Path ciphertextPath, long size, C
try {
return Cryptors.cleartextSize(size - cryptor.fileHeaderCryptor().headerSize(), cryptor);
} catch (IllegalArgumentException e) {
LOG.warn("Unable to calculate cleartext file size for " + ciphertextPath + ".", e);
LOG.warn("Unable to calculate cleartext file size for {}. Ciphertext size (including header): {}", ciphertextPath, size);
return 0l;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ public CleartextFileChannel(FileChannel ciphertextFileChannel, FileHeaderLoader
if (options.append()) {
position = fileSize.get();
}
headerWritten = !options.writable();
this.headerWritten = !options.writable();
if (options.createNew() || options.create()) {
lastModified.compareAndSet(Instant.EPOCH, Instant.now());
}
}

@Override
Expand Down Expand Up @@ -163,6 +166,9 @@ private long writeLockedInternal(ByteSource src, long position) throws IOExcepti
long newSize = fileSize.updateAndGet(size -> max(minSize, size));
assert newSize >= minSize;
lastModified.set(Instant.now());
if (options.syncData()) {
forceInternal(options.syncDataAndMetadata());
}
stats.addBytesWritten(written);
return written;
}
Expand Down Expand Up @@ -205,9 +211,13 @@ private void forceInternal(boolean metaData) throws IOException {
writeHeaderIfNeeded();
chunkCache.invalidateAll(); // TODO performance: write chunks but keep them cached
exceptionsDuringWrite.throwIfPresent();
attrViewProvider.get().setTimes(FileTime.from(lastModified.get()), null, null);
}
ciphertextFileChannel.force(metaData);
if (metaData) {
FileTime lastModifiedTime = isWritable() ? FileTime.from(lastModified.get()) : null;
FileTime lastAccessTime = FileTime.from(Instant.now());
attrViewProvider.get().setTimes(lastModifiedTime, lastAccessTime, null);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public Supplier<BasicFileAttributeView> provideBasicFileAttributeViewSupplier(@C
@OpenFileScoped
@OpenFileModifiedDate
public AtomicReference<Instant> provideLastModifiedDate(@OriginalOpenFilePath Path originalPath) {
Instant lastModifiedDate = readBasicAttributes(originalPath).map(BasicFileAttributes::lastModifiedTime).map(FileTime::toInstant).orElse(Instant.ofEpochMilli(0));
Instant lastModifiedDate = readBasicAttributes(originalPath).map(BasicFileAttributes::lastModifiedTime).map(FileTime::toInstant).orElse(Instant.EPOCH);
return new AtomicReference<>(lastModifiedDate);
}

Expand Down
Loading

0 comments on commit e2edee0

Please sign in to comment.