Skip to content

A failed re-fetch overwrote the mirrored file with the aborted read's debris - #763

Merged
xroche merged 4 commits into
masterfrom
fix/refetch-debris
Jul 27, 2026
Merged

A failed re-fetch overwrote the mirrored file with the aborted read's debris#763
xroche merged 4 commits into
masterfrom
fix/refetch-debris

Conversation

@xroche

@xroche xroche commented Jul 27, 2026

Copy link
Copy Markdown
Owner

A re-fetch whose connection dies before a complete response destroyed the file it was supposed to refresh. Nothing arrives, but the save path still consults r.adr, which by then holds whatever the aborted read left in the header buffer: raw status-line bytes on Linux, an empty buffer on macOS, where the mirrored file came out zero-length. Saving now requires a successful transfer, which is what the empty-body half of the condition already required.

The new test uses the HTTP 500 path as its control, since an error response on the same resource already keeps the previous copy. Purging is off there: an update purge deletes the same files for a separate reason (#746) and would mask this one.

Closes #748

xroche and others added 2 commits July 27, 2026 08:59
… debris

A transfer that dies before a complete response has no body, yet the save path
still consulted r.adr, which at that point holds whatever the aborted header
read left behind: raw status-line bytes, or an empty buffer that truncated the
file to zero on macOS. Require a successful transfer, as the empty-body half of
the condition already did.

Closes #748

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Xavier Roche <roche@httrack.com>
Test 93 filtered reset.bin out of its bucket lists because a connection killed
before the status line surfaced differently per platform. It no longer does, so
assert the resource like any other: unchanged, with the bytes pass 1 mirrored.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Xavier Roche <roche@httrack.com>
xroche and others added 2 commits July 27, 2026 09:18
The new test passed with no second pass at all, so a regression that stopped
re-fetching would have looked green. Assert the failure the fixture provokes,
give stay.bin a fresh pass-2 body so a fix that stopped overwriting anything
fails, and compare reset.bin by checksum rather than by length.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Xavier Roche <roche@httrack.com>
The message a cut connection produces depends on whether any bytes arrived, so
matching it would fail on a runner that sees none.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Xavier Roche <roche@httrack.com>
@xroche
xroche merged commit 99bd9bb into master Jul 27, 2026
22 checks passed
xroche added a commit that referenced this pull request Jul 27, 2026
Signed-off-by: Xavier Roche <roche@httrack.com>

# Conflicts:
#	src/htsback.c
#	tests/96_local-refetch-keep.test
xroche added a commit that referenced this pull request Jul 27, 2026
96 was taken by #763 on master.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Xavier Roche <roche@httrack.com>
@xroche
xroche deleted the fix/refetch-debris branch July 27, 2026 18:26
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.

A re-fetch that never gets a response truncates the mirrored file to zero on macOS

1 participant