Make subliminal always mangle cache keys to prevent long filenames

* Use dogpile.cache sha1_mangle_key to mangle cache keys

When using the subtitle hashes as cache keys, sometimes they come
out as filenames of 270 characters.
Not a lot of filesystems out there support filenames with over 250
characters.
This behaviour was reported with ext4 and zfs on both linux and FreeBSD.

The dogpile.cache utils come with a function that returns a hex digest
of the key, limiting the filename to a fixed length of 40 characters.

* Set region to subliminal.region and only then configure it, instead of assigning the result of configure to the property

* Make sure subliminal ALWAYS mangles keys with the sha1 to prevent filenames that are too long
pull/1317/head
Michiel van Baak 4 years ago committed by GitHub
parent c68377f40d
commit 87fbd196a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -11,9 +11,7 @@ from get_args import args
from logger import configure_logging
from helper import path_mappings
from dogpile.cache import make_region
from dogpile.cache.region import register_backend as register_cache_backend
from dogpile.cache.util import sha1_mangle_key
import subliminal
import datetime
@ -116,10 +114,7 @@ db_upgrade()
# Configure dogpile file caching for Subliminal request
register_cache_backend("subzero.cache.file", "subzero.cache_backends.file", "SZFileBackend")
subliminal.region = make_region(
key_mangler=sha1_mangle_key
).configure(
subliminal.region.configure(
'subzero.cache.file',
expiration_time=datetime.timedelta(days=30),
arguments={'appname': "sz_cache", 'app_cache_dir': args.config_dir}

@ -3,6 +3,7 @@ from __future__ import absolute_import
import datetime
from dogpile.cache import make_region
from dogpile.cache.util import sha1_mangle_key
#: Expiration time for show caching
SHOW_EXPIRATION_TIME = datetime.timedelta(weeks=3).total_seconds()
@ -13,5 +14,5 @@ EPISODE_EXPIRATION_TIME = datetime.timedelta(days=3).total_seconds()
#: Expiration time for scraper searches
REFINER_EXPIRATION_TIME = datetime.timedelta(weeks=1).total_seconds()
region = make_region()
# Mangle keys to prevent long filenames
region = make_region(key_mangler=sha1_mangle_key)

Loading…
Cancel
Save