Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve Last Modification Date #528

Merged

Conversation

JustFanta01
Copy link
Contributor

@JustFanta01 JustFanta01 commented Apr 10, 2024

Hello guys 👋
This is our attempt to preserve the last modified date for various clouds [/issues/239]

Me, @WheelyMcBones and @taglioIsCoding have made changes for:

  • OneDrive: we used an async PATCH to modify the FileSystemInfo.lastModifiedDateTime property of the file we are uploading;
  • Google Drive: we modified the file metadata using the setModifiedTime(...) API;
  • DropBox: we used the withClientModified(...) API to modify the date;
  • WebDAV/NextCloud: Webdav doesn't provide a standard way for doing it. But OwnCloud/NextCloud use a custom header, the “X-OC-Mtime”, so we have added it to the upload request, passing the modified date;
  • pCloud: In the API call we provide the modified date as a parameter but we weren’t able to test it because the pCloud system does not allow us to register a new app.

At the moment we haven't implemented for:

  • LocalStorage: We haven't found a easy and feasible way to implement it for the LocalStorage. We've encountered some troubles with .setLastModifiedDate() and the contentResolver(...).query(..., DocumentsContract.Document.COLUMN_LAST_MODIFIED).
  • S3: As far as we know S3 doesn't allow to change the Last-Modified date metadata.

Finally we have run all the tests successfully!

Summary by CodeRabbit

  • New Features
    • Enhanced OneDrive integration to retrieve and update the last modified date of files.
    • Improved WebDav file handling to include setting a custom modified date during file uploads.

taglioIsCoding and others added 16 commits April 2, 2024 12:14
The UriBasedDataSource via the ContentResolverUtil can obtain the original last modification date of the source.
This info can pass through all architecture to the data layer and used by the various APIs.
No need of modified list because the last modified date was already fetched (not tested)
Onedrive provide a "fileSystemInfo resource type" [1] that contains properties that are reported by the device's local
file system for the local version of an item. To fetch the original last modified date we have to pass an additional
argument which will be stored server side and retrieved in a second moment.
In the uploadFile() method a new PATCH request have been added to update those info.
In the chunkedUploadFile() is sufficient add a property to the request.

When a CloudNode is created by the OnedriveCloudNodeFactory the fileSystemInfo are used.

[1] https://learn.microsoft.com/en-us/graph/api/resources/filesysteminfo?view=graph-rest-1.0#notes
@CLAassistant
Copy link

CLAassistant commented Apr 10, 2024

CLA assistant check
All committers have signed the CLA.

Copy link

coderabbitai bot commented Apr 10, 2024

Walkthrough

This update enhances file metadata handling across various cloud storage integrations in Cryptomator. It introduces mechanisms to preserve and accurately reflect the last modified dates of files, ensuring consistency and reliability in metadata management across different platforms and local encryption scenarios.

Changes

File Path Change Summary
.data/src/apiKey/java/org/cryptomator/data/cloud/* Modified handling of last modified dates for various cloud storage providers like OneDrive and pCloud.
.data/src/main/java/org/cryptomator/data/cloud/webdav/network/WebDavClient.kt Updated writeFile method to accept modifiedDate parameter.

Possibly related issues

🐰✨
Little bits and bytes, all in a row,
Timestamps and dates, now correct they show.
Across the clouds, through cryptic haze,
Files keep their times, in all their days.
Cheers to the devs, with minds so bright,
For keeping our data just right! 🌟📅
🐰💾


Recent Review Details

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between cd22b4b and 4dbcdb8.
Files selected for processing (1)
  • data/src/apiKey/java/org/cryptomator/data/cloud/onedrive/OnedriveCloudNodeFactory.kt (1 hunks)

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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

Copy link
Member

@SailReal SailReal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your input 💚, we are almost there!

Please have a look at my suggestions, also here are some more general notes
- In Kotlin, you do not need a semicolon at the end of a statement
- Use automatic formatting, some if statements are not formatted correctly, for example
- We still need to improve our gitignore, I know, but please don't commit the changes in the .idea files
- What about other WebDAV servers, have you found any headers we can set in addition to Nextcloud's?

I will test your changes and get back to you.

@SailReal SailReal added the pr:safe PR is considered safe for testing label Apr 10, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

@JustFanta01 JustFanta01 requested a review from SailReal April 18, 2024 16:13
Copy link
Member

@SailReal SailReal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are on the right track 👍

@SailReal
Copy link
Member

Have you found any other headers related to other WebDAV implementations that we can set to adjust the modification date on other servers as well?

@taglioIsCoding
Copy link
Contributor

Nope, we tried looking for other WebDav implementations but the documentations are pretty poor in terms of modification date headers, so we preferred to keep our focus on thumbnails implementation.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Copy link
Member

@SailReal SailReal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Thank you very much for your contribution!

@SailReal SailReal merged commit 1ef6bfe into cryptomator:develop Apr 22, 2024
1 check passed
@SailReal SailReal added this to the 1.10.1 milestone Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:safe PR is considered safe for testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants