Skip to content

Fix truncated content URI uploads#184

Open
zerox80 wants to merge 1 commit into
opencloud-eu:mainfrom
zerox80:fix/content-uri-upload-cache-validation
Open

Fix truncated content URI uploads#184
zerox80 wants to merge 1 commit into
opencloud-eu:mainfrom
zerox80:fix/content-uri-upload-cache-validation

Conversation

@zerox80
Copy link
Copy Markdown
Contributor

@zerox80 zerox80 commented Jun 4, 2026

Summary

Fixes #181 by preventing partially copied content:// upload cache files from being treated as valid upload sources.

Root cause

UploadFileFromContentUriWorker accepted any non-empty cache file. If the worker or process was interrupted while copying a large content:// file into local cache, a later retry could reuse that partial cache file, set the upload size from the truncated cache, and complete TUS successfully with the wrong bytes.

Changes

  • Validate existing cached upload files against the original OCTransfer.fileSize before upload.
  • Delete invalid cached files, clear stale TUS state, and recopy from the original content:// URI.
  • Copy into a .part file first, validate the copied size, then rename into the final cache path only after validation succeeds.
  • Add unit coverage for large exact sizes, partial non-zero cache files, larger-than-expected cache files, zero-byte cache files, and unknown expected sizes.

Validation

  • 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 :opencloudApp:compileOriginalDebugKotlin could not run locally for the same Java environment reason.

@zerox80 zerox80 marked this pull request as ready for review June 4, 2026 12:08
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