check_download_cache#
- astropy.utils.data.check_download_cache(pkgname='astropy')[source]#
Do a consistency check on the cache.
Note
Since v5.0, this function no longer returns anything.
Because the cache is shared by all versions of
astropy
in all virtualenvs run by your user, possibly concurrently, it could accumulate problems. This could lead to hard-to-debug problems or wasted space. This function detects a number of incorrect conditions, including nonexistent files that are indexed, files that are indexed but in the wrong place, and, if you request it, files whose content does not match the hash that is indexed.This function also returns a list of non-indexed files. A few will be associated with the shelve object; their exact names depend on the backend used but will probably be based on
urlmap
. The presence of other files probably indicates that something has gone wrong and inaccessible files have accumulated in the cache. These can be removed withclear_download_cache()
, either passing the filename returned here, or with no arguments to empty the entire cache and return it to a reasonable, if empty, state.- Parameters:
- pkgname
str
, optional The package name to use to locate the download cache, i.e., for
pkgname='astropy'
the default cache location is~/.astropy/cache
.
- pkgname
- Raises:
CacheDamaged
To indicate a problem with the cache contents; the exception contains a
.bad_files
attribute containing a set of filenames to allow the user to useclear_download_cache()
to remove the offending items.OSError
,RuntimeError
To indicate some problem with the cache structure. This may need a full
clear_download_cache()
to resolve, or may indicate some kind of misconfiguration.