cli: fix minor race condition in creating hpi_temp_dir

This commit is contained in:
Dima Gerasimov 2024-09-23 01:14:49 +01:00 committed by karlicoss
parent bf8af6c598
commit 6a6d157040

View file

@ -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)