Skip to content
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

Conversation

Vierkantor
Copy link
Contributor

@Vierkantor Vierkantor commented Jul 13, 2021

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 running leanproject 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?)

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 running
`leanproject get-cache` again and verifying the oleans are available.
Since the tempfile API is 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?)
mathlibtools/lib.py Outdated Show resolved Hide resolved
@PatrickMassot PatrickMassot merged commit 490605a into leanprover-community:master Jul 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants