From f8ca4ce512bdd31ed833544fff86c3312e225dd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 1 Nov 2023 13:27:36 +0100 Subject: [PATCH] Avoid race condition when making directories for database cache --- 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 1aec1f070d..2c8940d833 100644 --- a/trytond/trytond/tests/test_tryton.py +++ b/trytond/trytond/tests/test_tryton.py @@ -132,9 +132,8 @@ def restore_db_cache(name): def backup_db_cache(name): if DB_CACHE: - if (not DB_CACHE.startswith('postgresql://') - and not os.path.exists(DB_CACHE)): - os.makedirs(DB_CACHE) + if not DB_CACHE.startswith('postgresql://'): + os.makedirs(DB_CACHE, exist_ok=True) cache_file = _db_cache_file(DB_CACHE, name) if backend.name == 'sqlite': _sqlite_copy(cache_file)