Skip to content

Keep the mirrored file when an --update re-fetch comes in short - #584

Merged
xroche merged 3 commits into
masterfrom
fix-562-incomplete-transfer-purge
Jul 15, 2026
Merged

Keep the mirrored file when an --update re-fetch comes in short#584
xroche merged 3 commits into
masterfrom
fix-562-incomplete-transfer-purge

Conversation

@xroche

@xroche xroche commented Jul 15, 2026

Copy link
Copy Markdown
Owner

An --update re-fetch that arrives incomplete (the server declares a Content-Length it never delivers, or the connection drops mid-body) is correctly refused: httrack logs "incomplete transfer ... will be retried on the next update" and keeps the partial out of the cache. It then deleted the good local copy anyway. The bytes on disk were never touched; the file died in the end-of-update purge, because the incomplete-transfer branch returned before noting the surviving copy, so the URL was absent from new.lst and the purge treated it like a page that had vanished from the site.

The fix filenote()s the previous copy when it still exists, the same guard #560 added on the decode-failure path. This one is broader: it needs no content coding and no abort, so a plain HTML page reproduces it (confirmed with -X0, which turns the purge off and lets the file survive). The new test mirrors a page and a direct-to-disk file, re-fetches both truncated under --update, and checks they keep their pass-1 content while a fully-served control still updates; reverting the fix deletes the files.

Closes #562

xroche and others added 3 commits July 15, 2026 08:54
An --update re-fetch that arrives incomplete (server declares a Content-Length
it does not deliver, or the connection drops mid-body) is correctly refused:
httrack logs "incomplete transfer ... will be retried on the next update" and
does not store the partial body. But the incomplete-transfer branch in
back_finalize() returned without noting the surviving copy, so the URL never
reached new.lst and the end-of-update purge deleted the good file it had just
declined to overwrite.

filenote() the previous copy when it still exists on disk, mirroring the
decode-failure path added in #560. Not compression-specific and needs no abort:
a plain HTML page reproduces it, so it is broader than #521 (abort) and #557
(decode failure).

Closes #562

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Xavier Roche <roche@httrack.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Xavier Roche <roche@httrack.com>
The #562 /uptrunc/ routes copied upcodec's per-path body-fetch counter verbatim. Fold both onto one refetch_pass() helper and one dict.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Xavier Roche <roche@httrack.com>
@xroche
xroche merged commit 800d498 into master Jul 15, 2026
21 checks passed
@xroche
xroche deleted the fix-562-incomplete-transfer-purge branch July 27, 2026 18:25
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.

--update: an incomplete transfer deletes the previously-mirrored file

1 participant