Repository navigation
Recover TUS uploads whose resume URL is no longer valid - #1145
Merged
Merged
Conversation
TheOneRing
force-pushed
the
fix/tus-stale-resume
branch
from
October 8, 2026 14:07
8799d56 to
7b67677
Compare
TheOneRing
requested changes
Oct 8, 2026
Mortimer-RR
force-pushed
the
fix/tus-stale-resume
branch
from
October 9, 2026 04:05
7b67677 to
1df8afc
Compare
Contributor
Author
|
Addressed the two notes from the @github-advanced-security bot, and reworded the commit to follow the AI guideline (Co-Authored-By replaced with an Assisted-by tag). @TheOneRing This PR adds a new FakeTusServer for the tests. The shared fake server in test/testutils/syncenginetestutils.cpp doesn’t support TUS yet. I have a local version that adds TUS support in Would you like me to include that in this PR, create a new PR that includes it, or should I keep the test as is. |
Contributor
|
I think the change is fine as is. thx. |
The saved resume info of a TUS upload was only cleared after a successful upload. When the server discarded an upload (for example after rejecting it with 460 Checksum Mismatch, or when it expired), the next sync sent HEAD to the old upload URL, got 404, and failed without clearing the resume info. The file then never synced until it was modified locally. The same happened when the transfer token embedded in the URL had expired and the data gateway answered 403. - If the resume HEAD fails with 404, 410 or 403, clear the resume info and start a new upload from offset 0 in the same run (once per job). - Clear the resume info when the server answers 460 Checksum Mismatch, so the next attempt starts a new upload. Tests use a small fake tus server in testtusresume. Assisted-by: Claude:claude-opus-5-5
TheOneRing
force-pushed
the
fix/tus-stale-resume
branch
from
October 12, 2026 11:47
1df8afc to
fd2309d
Compare
TheOneRing
enabled auto-merge (rebase)
October 12, 2026 11:48
TheOneRing
approved these changes
Oct 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1144 . Completes #898 together with #971: #971 recovers from a 409 on a PATCH; this
handles the resume HEAD failing because the upload is gone, which #971 skips.
Changes
src/libsync/propagateuploadtus.cppPropagateUploadFileTUS::slotChunkFinished(+ a member in
propagateuploadtus.h):the upload) or 403 (the transfer token embedded in the URL expired), clear the saved
resume info, reset
_locationand_currentOffset, and start a new creation-with-uploadin the same run. At most once per propagation job (
_restartedUpload), so a genuine 403can't loop: the new upload's own error is reported normally.
clear the saved resume info before the normal error handling, so the next attempt starts
a new upload instead of resuming a dead URL.
classifyErroris unchanged: 460 falls through toNormalError(retried).Tests
test/testtusresume.cpp(added by #971) gets a small fake tus server on top of the fake remote(creation-with-upload POST, PATCH, HEAD):
testResumeFromServerOffset: an interrupted upload still resumes from the server offset(HEAD, PATCH, PATCH); passes before and after.
testStaleResumeInfoRestartsUpload(data rows 404, 410, 403): the server lost the upload;the file uploads in the same sync (HEAD, POST, PATCH, PATCH) and the resume info is gone.
Fails on
main: the sync fails.testChecksumMismatchClearsResumeInfo: 460 on the last PATCH clears the resume info; thenext sync starts with POST. Fails on
main: the resume info is kept.All 35 tests pass (Linux, Qt 6.11.2).
git clang-formatclean.End to end against a server with the reva fixes: a deliberately corrupted upload was
rejected with 460 and uploaded successfully on the next sync, and the client recovered from a
forced 5-minute chunk timeout and two dropped PATCH connections.
🤖 Generated with Claude Code