Skip to content

Commit

Permalink
fix(toolkit): rename to a tmp dir before deleting (#414)
Browse files Browse the repository at this point in the history
fix(toolkit): move to a tmp dir before deleting
  • Loading branch information
efiop authored Feb 13, 2025
1 parent cd36d47 commit fca3541
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion projects/fal/src/fal/toolkit/utils/download_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,11 @@ def clone_repository(
f"Forcing re-download."
)
print(f"Removing the existing repository: {local_repo_path} ")
shutil.rmtree(local_repo_path)
with TemporaryDirectory(
dir=target_dir, suffix=f"{local_repo_path.name}.tmp.old"
) as tmp_dir:
os.rename(local_repo_path, tmp_dir)
shutil.rmtree(tmp_dir)

# 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 fca3541

Please sign in to comment.