From ba25580b19dc6be4cd12c41661d13c7ab9d2e952 Mon Sep 17 00:00:00 2001 From: Robert Imschweiler Date: Tue, 27 Apr 2021 12:18:45 +0200 Subject: [PATCH] clean-unused-caches: Handle non-existent yarn cache. --- scripts/lib/clean_yarn_cache.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/scripts/lib/clean_yarn_cache.py b/scripts/lib/clean_yarn_cache.py index 2383859e8c..1cc2687e05 100644 --- a/scripts/lib/clean_yarn_cache.py +++ b/scripts/lib/clean_yarn_cache.py @@ -20,13 +20,16 @@ def remove_unused_versions_dir(args: argparse.Namespace) -> None: can always remove the cache entirely. """ current_version_dir = os.path.join(YARN_CACHE_PATH, CURRENT_VERSION) - dirs_to_purge = set( - [ - os.path.join(YARN_CACHE_PATH, directory) - for directory in os.listdir(YARN_CACHE_PATH) - if directory != CURRENT_VERSION - ] - ) + try: + dirs_to_purge = set( + [ + os.path.join(YARN_CACHE_PATH, directory) + for directory in os.listdir(YARN_CACHE_PATH) + if directory != CURRENT_VERSION + ] + ) + except FileNotFoundError: + return may_be_perform_purging( dirs_to_purge,