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.
pull/1316/head
Michiel van Baak 4 years ago committed by GitHub
parent cdaa38f6f1
commit 7789f8c1a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -11,7 +11,9 @@ from get_args import args
from logger import configure_logging from logger import configure_logging
from helper import path_mappings 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.region import register_backend as register_cache_backend
from dogpile.cache.util import sha1_mangle_key
import subliminal import subliminal
import datetime import datetime
@ -109,12 +111,19 @@ if not os.path.exists(os.path.join(args.config_dir, 'db', 'bazarr.db')):
# upgrade database schema # upgrade database schema
from database import db_upgrade from database import db_upgrade
db_upgrade() db_upgrade()
# Configure dogpile file caching for Subliminal request # Configure dogpile file caching for Subliminal request
register_cache_backend("subzero.cache.file", "subzero.cache_backends.file", "SZFileBackend") register_cache_backend("subzero.cache.file", "subzero.cache_backends.file", "SZFileBackend")
subliminal.region.configure('subzero.cache.file', expiration_time=datetime.timedelta(days=30),
arguments={'appname': "sz_cache", 'app_cache_dir': args.config_dir}) subliminal.region = make_region(
key_mangler=sha1_mangle_key
).configure(
'subzero.cache.file',
expiration_time=datetime.timedelta(days=30),
arguments={'appname': "sz_cache", 'app_cache_dir': args.config_dir}
)
subliminal.region.backend.sync() subliminal.region.backend.sync()
if not os.path.exists(os.path.join(args.config_dir, 'config', 'releases.txt')): if not os.path.exists(os.path.join(args.config_dir, 'config', 'releases.txt')):

Loading…
Cancel
Save