From 6a6d15704063c328f9bf66330630a53a0c421915 Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Mon, 23 Sep 2024 01:14:49 +0100 Subject: [PATCH] cli: fix minor race condition in creating hpi_temp_dir --- my/core/__main__.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/my/core/__main__.py b/my/core/__main__.py index 9ec637c6..a80aa521 100644 --- a/my/core/__main__.py +++ b/my/core/__main__.py @@ -615,9 +615,8 @@ def main(*, debug: bool) -> None: # to run things at the end (would need to use a callback or pass context) # https://click.palletsprojects.com/en/7.x/commands/#nested-handling-and-contexts - tdir: str = os.path.join(tempfile.gettempdir(), 'hpi_temp_dir') - if not os.path.exists(tdir): - os.makedirs(tdir) + tdir = Path(tempfile.gettempdir()) / 'hpi_temp_dir' + tdir.mkdir(exist_ok=True) os.chdir(tdir)