Skip to content

Commit

Permalink
cache: version the file using the library version instead
Browse files Browse the repository at this point in the history
so we don't have to care about this in the future.
  • Loading branch information
lazka committed Mar 3, 2024
1 parent 719254c commit bf9a4e2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion msys2_autobuild/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit bf9a4e2

Please sign in to comment.