Cache.download()
deletes an expired file before knowing that it can download a new version of the file
#7249
Labels
Bug
Probably a bug
data
Affects the data submodule
Effort Low
Requires a small time investment
Good First Issue
The best issues for new people to tackle!
Package Intermediate
Requires some knowledge of the internal structure of SunPy
Priority Low
Slow action required
Provide a general description of the issue or problem.
The
download()
method of ourCache
class deletes an expired file:sunpy/sunpy/data/data_manager/cache.py
Lines 76 to 79 in 7821330
before attempting to download a new version of the file:
sunpy/sunpy/data/data_manager/cache.py
Line 84 in 7821330
That means that if the download does not succeed for whatever reason, the user now has no copy of the file. Such a harsh application of expiration would be appropriate if we were dealing with time bombs, but for virtually all use cases, an expired file is just as usable as a new version.
We should not delete the expired file until after successfully downloading a new version of the file. If the downloading fails, we retain the expired file, and we can emit a warning to the user that they will be working with a potentially stale file.
The text was updated successfully, but these errors were encountered: