Skip to content

Add original checksums for TUS uploads#185

Open
zerox80 wants to merge 1 commit into
opencloud-eu:mainfrom
zerox80:fix/tus-original-checksum
Open

Add original checksums for TUS uploads#185
zerox80 wants to merge 1 commit into
opencloud-eu:mainfrom
zerox80:fix/tus-original-checksum

Conversation

@zerox80
Copy link
Copy Markdown
Contributor

@zerox80 zerox80 commented Jun 4, 2026

Summary

Adds client-computed SHA1 checksums for TUS uploads so OpenCloud receives the checksum of the original upload source instead of a late checksum over whatever file is about to be uploaded.

This PR also includes the content-URI cache validation from #184 because that PR is not merged yet. Without that validation, a stale partial cache file could still be reused before the checksum path has a trustworthy original source.

Changes

  • Compute SHA1 from the original local file or original content:// stream before creating a TUS upload.
  • Persist the checksum in the existing tusUploadChecksum column as sha1:<hex> so retries and recreated sessions use the same source checksum.
  • Send the checksum in TUS Upload-Metadata as checksum = SHA1 <hex>.
  • Disable creation-with-upload for checked uploads so all bytes are sent through PATCH chunks.
  • Send Upload-Checksum: sha1 <base64(raw chunk sha1)> on each TUS PATCH.
  • Treat checksum rejection (400 / 460) as a retryable TUS failure instead of falling back to unchecked PUT.
  • Validate content-URI cache files against the original transfer size and copy through .part files before upload.

Validation

  • git diff --check passed.
  • git diff --cached --check passed before commit.
  • ./gradlew.bat :opencloudApp:testOriginalDebugUnitTest could not run locally: JAVA_HOME is not set and no java executable is available in PATH.
  • ./gradlew.bat :opencloudComLibrary:testDebugUnitTest could not run locally for the same Java environment reason.
  • ./gradlew.bat :opencloudApp:compileOriginalDebugKotlin could not run locally for the same Java environment reason.

Fixes #181 when combined with the included partial-cache validation.
Depends on / supersedes #184 if this PR is merged first.

@zerox80 zerox80 marked this pull request as ready for review June 4, 2026 15:07
@guruz guruz self-requested a review June 4, 2026 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android app truncate large (multi-gigabyte) files during camera upload

1 participant