re-create tmpdir after successfull rename

This patch adds a workaround for python versions < 3.8.
There, the dir created by TemporaryDirectory must still exist when
leaving the context manager.

Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
Felix Moessbauer 2023-01-05 08:50:22 +01:00 committed by Jan Kiszka
parent f2560588bc
commit 3289ec2a7e

View File

@ -200,6 +200,9 @@ class RepoImpl(Repo):
logging.debug('Created repo ref for %s', self.qualified_name)
try:
os.rename(tmpdir, sdir)
if sys.version_info < (3, 8):
# recreate dir so cleanup handler can delete it
os.makedirs(tmpdir, exist_ok=True)
except OSError:
logging.debug('repo %s already cloned by other instance',
self.qualified_name)