Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create backup of the download cache before deleting it #24

Open
wants to merge 2 commits into
base: utils/remove-cache-if-loading-it-fails
Choose a base branch
from

Conversation

embray
Copy link

@embray embray commented Jul 6, 2015

(adds a new optional 'backup' argument to clear_download_cache). Also includes fixes to correctly determine the urlmap filename on Python 3, and to catch the correct exception from the dbm module on Python 3 (a 'dbm.error' exception is raised, not an ImportError)

embray added 2 commits July 6, 2015 11:11
…tional 'backup' argument to clear_download_cache). Also includes fixes to correctly determine the urlmap filename on Python 3, and to catch the correct exception from the dbm module on Python 3 (a 'dbm.error' exception is raised, not an ImportError)
cache_backups = clear_download_cache(backup=True)
warn(msg + ' A new cache will be created, but a backup of '
'the old cache was saved to {0} and {1}.'.format(
*cache_backups), AstropyWarning)
Copy link
Author

Choose a reason for hiding this comment

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

In addition to making a new db file named from the db library in use, I think this can be simplified a bit to not actually make a backup of all the cached files. They can just stay right where they are. If the cleared cache DB is used then some already existing files will still be re-downloaded unnecessarily, but then once we get their hash we can just check if the file already exists and leave it there. I think there's probably no harm in that. The worse that can happen is that that there are saved files that are not in the DB. We could later add a cleanup method for that if it really comes to it.

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.

1 participant