nextcloud / nextcloud/server

Generate file checksum on upload

Open
#56,057 12 comments 26 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

0. Needs triage enhancement hotspot: file transfer performance
Dominant language
PHP
Stars
36.9k
Forks
5.2k
Avg merge
2d 3h
Merged PRs (30d)
713

Description

How to use GitHub
  • Please use the 👍 reaction to show that you are interested into the same feature.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

Is your feature request related to a problem? Please describe.

While working on nextcloud/files-clients#42 and nextcloud/android#19, I came up with an experimental concept to improve synchronisation with mobile clients and introduce robust bidirectional synchronisation for the Android client.

For this concept to work, the server needs to provide a history of the files in question. This can be provided via the files_versions app. Another requirement is the introduction of server-side checksums. This allows clients to locally check the current file against a backlog of versions to improve the handling of file conflicts and minimise manual intervention.

Describe the solution you'd like

To be concrete: I would like the versioning record for each file version to be extended to include a checksum of the actual file content. The checksum can either be calculated when a file version is created (persisted to memory), or on demand, when a client queries the corresponding property.

Ideally the current response would be extended to the following:

<d:propstat>
  <d:prop>
    <d:getcontentlength>3524</d:getcontentlength>
    <d:getcontenttype>text/plain</d:getcontenttype>
    <d:getlastmodified>Thu, 6 Feb 2025 21:36:17 GMT</d:getlastmodified>
    <d:getetag>1738877777</d:getetag>
    <nc:version-author>user</nc:version-author>
    <nc:has-preview>true</nc:has-preview>

    <oc:checksum>md5:16d15276ca33bd0212c871fae86947f2</oc:checksum>

  </d:prop>
  <d:status>HTTP/1.1 200 OK</d:status>
</d:propstat>

Including <oc:checksum> for any individual version.

Describe alternatives you've considered

Several alternative approaches have been considered. These would entail major changes to the way mobile clients interact with the server and have thus been ruled out.

Additional context

Server-side checksums can already be requested by querying the <oc:checksums /> property of files. Clients can also request that the server hashes a given file on demand using ChecksumUpdatePlugin.

The implementation of this concept is part of an academic project. Any comments, discussions or contributions on the implementation or viability of the proposed solution are welcome.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the apps/files_versions app and apps/dav/lib/Connector/Sabre/ChecksumUpdatePlugin.php, then trace how version records and WebDAV properties are exposed. Check the existing oc:checksums property and related DAV tests before deciding where the version checksum belongs. Done means an individual file version returns an oc:checksum property with its content checksum without breaking existing responses.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.