Skip to content

Commit

Permalink
Fix permission issue when downloading on root dir (#2367)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wauplin authored Jul 5, 2024
1 parent 79f51dc commit f79eaf8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/huggingface_hub/file_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -1939,7 +1939,12 @@ def _chmod_and_move(src: Path, dst: Path) -> None:
cache_dir_mode = Path(tmp_file).stat().st_mode
os.chmod(str(src), stat.S_IMODE(cache_dir_mode))
finally:
tmp_file.unlink()
try:
tmp_file.unlink()
except OSError:
# fails if `tmp_file.touch()` failed => do nothing
# See https://github.com/huggingface/huggingface_hub/issues/2359
pass

shutil.move(str(src), str(dst))

Expand Down

0 comments on commit f79eaf8

Please sign in to comment.