Skip to content

fix(libsync): resume a TUS upload from the server's offset on a 409 mismatch - #971

Merged
TheOneRing merged 1 commit into
opencloud-eu:mainfrom
bernardgut:fix/tus-409-offset-resume
Jul 22, 2026
Merged

TheOneRing merged 1 commit into
opencloud-eu:mainfrom
bernardgut:fix/tus-409-offset-resume

Conversation

@bernardgut

Copy link
Copy Markdown
Contributor

Second half of the #960 split. Fixes #898.

Problem

A stale TUS resume gets HTTP 409 (Upload-Offset mismatch) and falls into commonErrorHandling, where the upload wedges: the file hangs near 100% and only a manual remove and re-add of the folder recovers it (#898).

Fix

  • PropagateUploadFileTUS::slotChunkFinished() now handles a 409 like a timeout: HEAD the upload to get the server's current offset and resume from there.
  • As a fallback, classifyError() maps 409 to SoftError and sets anotherSyncNeeded, so the file is retried instead of being finalized with a silent gap.

Tests

test/testtusresume.cpp pins the classifyError fallback (fails pre-fix, passes with the fix). The transport recovery reuses the existing timeout path rather than adding a new one.

Full ctest on the CI image: 31/32. The one failure is testfolderwatcher, environment-only on my build host (inotify limit, unrelated).

Fixes #898

…ismatch

A stale or diverged TUS resume gets HTTP 409 (Upload-Offset mismatch). It
used to fall through to commonErrorHandling and the upload wedged: the file
hangs near 100%, never completes, and recovery needs a manual remove and
re-add of the sync folder.

Route a 409 in PropagateUploadFileTUS::slotChunkFinished() through the same
HEAD-to-get-current-offset recovery path already used for timeouts, so the
upload resumes from the server's canonical Upload-Offset. classifyError()
additionally maps 409 to a recoverable SoftError that sets anotherSyncNeeded
as a fallback, so the file is retried and the run re-discovered instead of
being finalized with a silent gap.

test/testtusresume.cpp pins the classifyError fallback contract
(bug-bites-verified: fails against the pre-fix classifyError).

Fixes opencloud-eu#898

Authored-By: Bernard Gütermann <[email protected]>
@TheOneRing

Copy link
Copy Markdown
Contributor

Thank you for your contribution

@TheOneRing
TheOneRing enabled auto-merge (rebase) July 13, 2026 08:56
@TheOneRing

Copy link
Copy Markdown
Contributor

The crashing unit test is unrelated

@TheOneRing
TheOneRing disabled auto-merge July 22, 2026 10:40
@TheOneRing
TheOneRing merged commit da297ae into opencloud-eu:main Jul 22, 2026
11 of 15 checks passed
@openclouders openclouders mentioned this pull request Jul 22, 2026
1 task
@saw-jan saw-jan mentioned this pull request Sep 2, 2026
9 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TUS uploads can get permanently stuck after failed resume; stale uploadinfo is not reset since 3.0

2 participants