diff options
| author | Ben Cail <bcail@crossway.org> | 2024-03-20 16:46:28 -0400 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2024-03-21 20:15:41 +0100 |
| commit | 8dbfef469582128c9d8487bf3f45d861b2ecfcb9 (patch) | |
| tree | 305a1873cf2f081c1a4e96ad3ea1f4cab36ae4f0 | |
| parent | 6a37e9bfae42eb180a8c978a3ade5b41c97c26b1 (diff) | |
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.
| -rw-r--r-- | django/core/files/move.py | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/django/core/files/move.py b/django/core/files/move.py index 95d69f9d94..b25a1c8b2d 100644 --- a/django/core/files/move.py +++ b/django/core/files/move.py @@ -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): |
