Skip to content

Download: do not remove a target file that existed beforehand - #107

Open
fingolfin wants to merge 1 commit into
masterfrom
mh/download-keep-existing
Open

Download: do not remove a target file that existed beforehand#107
fingolfin wants to merge 1 commit into
masterfrom
mh/download-keep-existing

Conversation

@fingolfin

@fingolfin fingolfin commented Aug 23, 2026

Copy link
Copy Markdown
Member

The clean-up added in #103 removes opt.target after any failed method, which also removes a file that was there before the call. A failed download then destroys a file it never created.

Remember whether the file existed when Download was entered, and remove it only if it did not.

This also lets the wget method drop its own removal: with the caller's file protected in one place, the per-method clean-up is redundant, and RemoveFile is now called from exactly one place instead of two that disagreed about whether to signal an error when it fails.

The clean-up added in #103 removes 'opt.target' after any failed method,
which also removes a file that was there before the call.  A failed
download then destroys a file it never created.

Remember whether the file existed when 'Download' was entered, and remove
it only if it did not.

This also lets the wget method drop its own removal: with the caller's
file protected in one place, the per-method clean-up is redundant, and
'RemoveFile' is now called from exactly one place instead of two that
disagreed about whether to signal an error when it fails.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@fingolfin
fingolfin requested a review from ThomasBreuer August 23, 2026 22:14
@codecov

codecov Bot commented Aug 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.38%. Comparing base (3db5598) to head (02591d1).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #107      +/-   ##
==========================================
+ Coverage   86.33%   86.38%   +0.04%     
==========================================
  Files          32       32              
  Lines        1910     1909       -1     
==========================================
  Hits         1649     1649              
+ Misses        261      260       -1     
Files with missing lines Coverage Δ
lib/download.gi 94.11% <100.00%> (+0.45%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ThomasBreuer ThomasBreuer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea.

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