Skip to content

Commit

Permalink
fix(toolkit): move to a tmp dir before deleting
Browse files Browse the repository at this point in the history
  • Loading branch information
efiop committed Feb 13, 2025
1 parent cd36d47 commit ec5831b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion projects/fal/src/fal/toolkit/utils/download_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import shutil
import subprocess
import sys
import uuid
from pathlib import Path, PurePath
from tempfile import NamedTemporaryFile, TemporaryDirectory
from urllib.parse import urlparse
Expand Down Expand Up @@ -416,7 +417,9 @@ def clone_repository(
f"Forcing re-download."
)
print(f"Removing the existing repository: {local_repo_path} ")
shutil.rmtree(local_repo_path)
tmp_path = local_repo_path.with_suffix(uuid.uuid4().hex[:3])
os.rename(local_repo_path, tmp_path)
shutil.rmtree(tmp_path)

# NOTE: using the target_dir to be able to avoid potential copies across temp fs
# and target fs, and also to be able to atomically rename repo_name dir into place
Expand Down

0 comments on commit ec5831b

Please sign in to comment.