From 4779c72913e2fdcd428489ca6173b9247ff5b20e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 26 Nov 2023 17:12:40 +0100 Subject: [PATCH] Limit size of database cache dump to 40 chars Each backend has their limit. 40 chars is picked as limit to match the size of mercurial hash. Closes #12754 --- trytond/trytond/tests/test_tryton.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/trytond/trytond/tests/test_tryton.py b/trytond/trytond/tests/test_tryton.py index 2c8940d833..b8dc2d9a99 100644 --- a/trytond/trytond/tests/test_tryton.py +++ b/trytond/trytond/tests/test_tryton.py @@ -142,12 +142,11 @@ def backup_db_cache(name): def _db_cache_file(path, name): + hash_name = hashlib.shake_128(name.encode('utf8')).hexdigest(40 // 2) if DB_CACHE.startswith('postgresql://'): - hash_name = hashlib.shake_128(name.encode('utf8')).hexdigest( - (63 - len('test-')) // 2) return f"{DB_CACHE}/test-{hash_name}" else: - return os.path.join(path, '%s-%s.dump' % (name, backend.name)) + return os.path.join(path, f'{hash_name}-{backend.name}.dump') def _sqlite_copy(file_, restore=False):