Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(toolkit): rename to a tmp dir before deleting #414

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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