This repository has been archived by the owner on Aug 29, 2023. It is now read-only.
feat(leanproject): download to a tempfile #104
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If leanproject is downloading a file (e.g. mathlib oleans) and gets interrupted, we should not keep around the broken archive file. Otherwise, if you re-run the command, leanproject will think the partial download is in fact a complete archive and it will try to extract a broken file.
This PR fixes that issue by creating a temporary file in the
download
function and moving this over the target file when the download has completed successfully.I have successfully tested the changes on my Linux computer by running
leanproject get-cache
and interrupting the download, then runningleanproject get-cache
again and verifying the oleans are available. Since atomic operations are OS-specific, someone with access to a Windows computer should definitely test this PR as well.(Is there a way to insert a connection error in the middle of a download automatically, so we can add this functionality to the
tox
tests?)