From 3289ec2a7e82b443d68c4f89a1cd3ec2f2f01773 Mon Sep 17 00:00:00 2001 From: Felix Moessbauer Date: Thu, 5 Jan 2023 08:50:22 +0100 Subject: [PATCH] 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 Signed-off-by: Jan Kiszka --- kas/repos.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kas/repos.py b/kas/repos.py index f708dc9..cfec816 100644 --- a/kas/repos.py +++ b/kas/repos.py @@ -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)