From 670e1c373b33948668096628535a3cc5e2369c21 Mon Sep 17 00:00:00 2001 From: teleprint-me <77757836+teleprint-me@users.noreply.github.com> Date: Tue, 7 May 2024 21:59:58 -0400 Subject: [PATCH] fix: Attempt to remove potential TOCTOU --- convert-hf-to-gguf-update.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/convert-hf-to-gguf-update.py b/convert-hf-to-gguf-update.py index 6c01bd169..52f217ef5 100755 --- a/convert-hf-to-gguf-update.py +++ b/convert-hf-to-gguf-update.py @@ -109,12 +109,12 @@ for model in models: model_config_path = f"{model_name_or_path}/config.json" # check dir path - if not os.path.exists(model_name_or_path): # TOCTOU - os.makedirs(model_name_or_path) - else: + if os.path.exists(model_name_or_path): # Still TOCTOU? logger.info(f"Directory {model_name_or_path} already exists - skipping") continue + os.makedirs(model_name_or_path, exist_ok=True) + logger.info(f"Downloading {name} to {model_name_or_path}") # model and repo urls are not the same