From bf9a4e2862759980634374105c3413ff421cde14 Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Sun, 3 Mar 2024 07:32:38 +0100 Subject: [PATCH] cache: version the file using the library version instead so we don't have to care about this in the future. --- msys2_autobuild/utils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/msys2_autobuild/utils.py b/msys2_autobuild/utils.py index 2e2b84b..d16a26a 100644 --- a/msys2_autobuild/utils.py +++ b/msys2_autobuild/utils.py @@ -43,11 +43,16 @@ def install_requests_cache() -> Generator: # github sends by default with 60 seconds. cache_dir = os.path.join(os.getcwd(), '.autobuild_cache') os.makedirs(cache_dir, exist_ok=True) + cache_file = f'http_cache_{requests_cache.__version__}.sqlite' + # delete other versions + for f in os.listdir(cache_dir): + if f.startswith('http_cache_') and f != cache_file: + os.remove(os.path.join(cache_dir, f)) requests_cache.install_cache( always_revalidate=True, cache_control=False, expire_after=requests_cache.EXPIRE_IMMEDIATELY, - backend=SQLiteCache(os.path.join(cache_dir, 'http_cache_2.sqlite'))) + backend=SQLiteCache(os.path.join(cache_dir, cache_file))) # Call this once, so it gets cached from the main thread and can be used in a thread pool get_requests_session(nocache=True)