clean-unused-caches: Handle non-existent yarn cache.

This commit is contained in:
Robert Imschweiler
2021-04-27 12:18:45 +02:00
committed by Tim Abbott
parent 08f6214829
commit ba25580b19

View File

@@ -20,13 +20,16 @@ def remove_unused_versions_dir(args: argparse.Namespace) -> None:
can always remove the cache entirely. can always remove the cache entirely.
""" """
current_version_dir = os.path.join(YARN_CACHE_PATH, CURRENT_VERSION) current_version_dir = os.path.join(YARN_CACHE_PATH, CURRENT_VERSION)
dirs_to_purge = set( try:
[ dirs_to_purge = set(
os.path.join(YARN_CACHE_PATH, directory) [
for directory in os.listdir(YARN_CACHE_PATH) os.path.join(YARN_CACHE_PATH, directory)
if directory != CURRENT_VERSION for directory in os.listdir(YARN_CACHE_PATH)
] if directory != CURRENT_VERSION
) ]
)
except FileNotFoundError:
return
may_be_perform_purging( may_be_perform_purging(
dirs_to_purge, dirs_to_purge,