mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Fixed #35320 -- Removed unnecessary django.core.files.move._samefile() hook.
os.path.samefile() uses the same implementation on Windows as all other platforms since Python 3.4.
This commit is contained in:
parent
6a37e9bfae
commit
8dbfef4695
@ -13,20 +13,6 @@ from django.core.files import locks
|
||||
__all__ = ["file_move_safe"]
|
||||
|
||||
|
||||
def _samefile(src, dst):
|
||||
# Macintosh, Unix.
|
||||
if hasattr(os.path, "samefile"):
|
||||
try:
|
||||
return os.path.samefile(src, dst)
|
||||
except OSError:
|
||||
return False
|
||||
|
||||
# All other platforms: check for same pathname.
|
||||
return os.path.normcase(os.path.abspath(src)) == os.path.normcase(
|
||||
os.path.abspath(dst)
|
||||
)
|
||||
|
||||
|
||||
def file_move_safe(
|
||||
old_file_name, new_file_name, chunk_size=1024 * 64, allow_overwrite=False
|
||||
):
|
||||
@ -40,8 +26,11 @@ def file_move_safe(
|
||||
``FileExistsError``.
|
||||
"""
|
||||
# There's no reason to move if we don't have to.
|
||||
if _samefile(old_file_name, new_file_name):
|
||||
return
|
||||
try:
|
||||
if os.path.samefile(old_file_name, new_file_name):
|
||||
return
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
try:
|
||||
if not allow_overwrite and os.access(new_file_name, os.F_OK):
|
||||
|
Loading…
Reference in New Issue
Block a user