Closed infeo closed 3 months ago
Overall, the changes improve the handling of file attributes and channel closures in the Cryptomator project. Key modifications include the restructuring of methods for better readability, the removal of unnecessary exception declarations, and enhanced testability. These adjustments ensure a more robust, maintainable, and test-friendly codebase.
File Path | Change Summary |
---|---|
src/.../CryptoBasicFileAttributeView.java |
Modified setTimes method to set ciphertext attributes before checking and setting last modified time. |
src/.../ChannelCloseListener.java |
Updated closed method signature to remove throws IOException . |
src/.../CleartextFileChannel.java |
Annotated flush with @VisibleForTesting , refactored implCloseChannel , and added new helper methods. |
src/.../OpenCryptoFile.java |
Refined channelClosed method to ensure correct file closure logic. |
src/test/.../CleartextFileChannelTest.java |
Removed unused imports and adjusted tests for new method signatures and order verification. |
sequenceDiagram
participant User
participant CryptoBasicFileAttributeView
participant Filesystem
participant CleartextFileChannel
participant OpenCryptoFile
User ->> CryptoBasicFileAttributeView: setTimes(lastModifiedTime, lastAccessTime, createTime)
CryptoBasicFileAttributeView ->> Filesystem: Set ciphertext attributes
CryptoBasicFileAttributeView ->> OpenCryptoFile: Check and set last modified time
User ->> CleartextFileChannel: Close Channel
CleartextFileChannel ->> OpenCryptoFile: channelClosed(cleartextFileChannel)
OpenCryptoFile ->> CleartextFileChannel: Close if no open channels
CleartextFileChannel ->> Filesystem: Flush and close
In Cryptomator's code we delve,
Refactoring methods, oh so swell.
Channels close with graceful ease,
Testing's simpler, bugs appease.
Attributes set, secure and right,
In the codebase, shines the light.
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
This PR changes the logic of persisting the lastModfied date from before closing the ciphertext channel to afterwards. Additionally, the cryptofs internal lastModifiedDate is always updated, even when persisting to storage fails.
This impl change is motivated by the behaviour of some fs/storage implemenations, which set the lastModified time to "now" when closing a channel, regardless of changes made.
The test was to edit and save an spreadsheet/document file and copying files of different sizes into the vault.
1: iCloud on Windows is... strange. First of all, everything copied into the iCloud dir gets as mTime the current time. Inside a Cryptomator vault, this becomes even stranger. Sometimes, the files are set to the current time, but especially bigger files (<30MB) get ... "some" time. "Some" can be the current, the former file mTime or something in between.
2: On Linux there are no offical filesystem integrations. GNOME offers "online account", but these are not accessible from the filesystem.