fix: Attempt to remove potential TOCTOU

This commit is contained in:
teleprint-me 2024-05-07 21:59:58 -04:00
parent f7dda38b10
commit 670e1c373b
No known key found for this signature in database
GPG key ID: B0D11345E65C4D48

View file

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