Skip to content

Download: never leave the target file behind after a failure - #103

Merged
fingolfin merged 1 commit into
masterfrom
mh/download-target-cleanup
Aug 17, 2026
Merged

Download: never leave the target file behind after a failure#103
fingolfin merged 1 commit into
masterfrom
mh/download-target-cleanup

Conversation

@fingolfin

@fingolfin fingolfin commented Aug 11, 2026

Copy link
Copy Markdown
Member

With opt.target set and the download failing, the three methods disagree: via wget removes the partial file, via curl leaves it, and via SingleHTTPRequest writes the response body (a 404 error page) to the target and then reports failure. So whether the file exists afterwards, and what is in it, depends on which method was available.

Fix this by uniformly deleting the target file in case of a failure.

Written with Claude Opus 5 via Claude Code.

@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.33%. Comparing base (b7d9593) to head (93a5ff5).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #103      +/-   ##
==========================================
+ Coverage   86.30%   86.33%   +0.02%     
==========================================
  Files          32       32              
  Lines        1906     1910       +4     
==========================================
+ Hits         1645     1649       +4     
  Misses        261      261              
Files with missing lines Coverage Δ
lib/download.gi 93.65% <100.00%> (+0.12%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ThomasBreuer

Copy link
Copy Markdown
Contributor

I do not understand the "One question".
The wget based method calls RemoveFile in the situation that an unwanted file was written, and calls Error if the removal fails.
The proposed changes add RemoveFile calls in other methods, without checking whether the removal was successful. I think that for the sake of consistency, either all methods should trust RemoveFile, or all methods should check whether RemoveFile was successful, and call Error if not.

@fingolfin

Copy link
Copy Markdown
Member Author

Last week I was a conference and went a bit overboard with allowing my AI to open PRs without me double checking everything. That was a mistake and I apologize if I wasted anyone's time by having them stare at slop. (The "reviewed by me" was inserted by the AI without consulting with me -- but I should have caught it. Argh).

Anyway: I've marked this PR as "draft" for now, please don't merge it -- I'll carefully review and edit it, and will mark it as "ready for review" once I am satisfied. Don't waste your time on it for now (that said, of course you are welcome to leave feedback, but don't feel obliged to).

Clean up once in 'Download', after a method reports failure, rather than
in each method: the guarantee then holds for methods added to
'Download_Methods' from outside too, and there is one place to look.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@fingolfin
fingolfin force-pushed the mh/download-target-cleanup branch from a6c57c3 to 93a5ff5 Compare August 17, 2026 22:55
@fingolfin
fingolfin marked this pull request as ready for review August 17, 2026 22:55
@fingolfin
fingolfin merged commit 3db5598 into master Aug 17, 2026
3 of 4 checks passed
@fingolfin
fingolfin deleted the mh/download-target-cleanup branch August 17, 2026 22:55
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.

2 participants