1
0
Fork 0
mirror of https://github.com/kemayo/leech synced 2026-05-07 03:52:17 +02:00

Store cache in an OS temp directory

This commit is contained in:
David Lynch 2026-04-05 23:38:17 -05:00
parent 1eb877bd63
commit 7ab331a3a4
2 changed files with 4 additions and 1 deletions

View file

@ -34,9 +34,11 @@ def configure_logging(verbose):
def create_session(cache):
if cache:
session = requests_cache.CachedSession('leech', expire_after=4 * 3600)
session = requests_cache.CachedSession('leech', expire_after=4 * 3600, use_temp=True)
logger.debug("CachedSession at %s", session.cache.db_path)
else:
session = requests.Session()
logger.debug("Uncached session")
lwp_cookiejar = http.cookiejar.LWPCookieJar()
try:

View file

@ -214,6 +214,7 @@ class Site:
raise SiteException("Couldn't fetch", url)
if delay and delay > 0 and not page.from_cache:
time.sleep(delay)
logger.debug('Fetched %s, %s', url, page.from_cache and 'cached' or 'uncached')
text = page.text
fallback_base = url
else: