diff options
author | morpheus65535 <[email protected]> | 2021-03-14 12:36:52 -0400 |
---|---|---|
committer | GitHub <[email protected]> | 2021-03-14 12:36:52 -0400 |
commit | ea0662cbd25d6d2cddcf807b92579fe99561d005 (patch) | |
tree | 029ad6d38edc5d1d6c29ba503906e4ee5d8029d0 | |
parent | 99a529037d10f0b276396de310eafd9a0b4d2716 (diff) | |
parent | 9d73ccacf30f7931a64e6b25f0581ed1f604de53 (diff) | |
download | bazarr-ea0662cbd25d6d2cddcf807b92579fe99561d005.tar.gz bazarr-ea0662cbd25d6d2cddcf807b92579fe99561d005.zip |
Fixed filename too long with cache
Use sha1 digest as cache key
-rw-r--r-- | libs/subliminal/cache.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/libs/subliminal/cache.py b/libs/subliminal/cache.py index 3d8848e1d..da0312ba5 100644 --- a/libs/subliminal/cache.py +++ b/libs/subliminal/cache.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import import datetime +from hashlib import sha1 from dogpile.cache import make_region @@ -14,4 +15,13 @@ EPISODE_EXPIRATION_TIME = datetime.timedelta(days=3).total_seconds() REFINER_EXPIRATION_TIME = datetime.timedelta(weeks=1).total_seconds() -region = make_region() +def sha1_key_mangler(key): + """Return sha1 hex for cache keys""" + if isinstance(key, str): + key = key.encode("utf-8") + + return sha1(key).hexdigest() + + +# Use key mangler to limit cache key names to 40 characters +region = make_region(key_mangler=sha1_key_mangler) |