mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
Fixed #35323 -- Prevented file_move_safe() from trying to overwrite existing file when allow_overwrite is False.
This commit is contained in:
committed by
Mariusz Felisiak
parent
b6e2b83901
commit
07c8d979ae
@@ -32,13 +32,12 @@ def file_move_safe(
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
try:
|
||||
if not allow_overwrite and os.access(new_file_name, os.F_OK):
|
||||
raise FileExistsError(
|
||||
"Destination file %s exists and allow_overwrite is False."
|
||||
% new_file_name
|
||||
)
|
||||
if not allow_overwrite and os.access(new_file_name, os.F_OK):
|
||||
raise FileExistsError(
|
||||
f"Destination file {new_file_name} exists and allow_overwrite is False."
|
||||
)
|
||||
|
||||
try:
|
||||
os.rename(old_file_name, new_file_name)
|
||||
return
|
||||
except OSError:
|
||||
|
||||
Reference in New Issue
Block a user