[issue46763] os.path.samefile incorrect results for shadow copies

2022-02-16 Thread Eryk Sun
Eryk Sun added the comment: Sample implementation: import os import msvcrt import win32file def samefile(f1, f2): """Test whether two paths refer to the same file or directory.""" s1 = os.stat(f1) s2 = os.stat(f2) return _common_same_file(f1,

[issue46763] os.path.samefile incorrect results for shadow copies

2022-02-16 Thread Eryk Sun
Eryk Sun added the comment: Python uses the volume serial number (VSN) and file ID for st_dev and st_ino. The OS allows the file ID to be 0 if the filesystem doesn't support file IDs. Also, it does not require or force the VSN to be a unique ID in the system, though if it's not 0 it's

[issue46763] os.path.samefile incorrect results for shadow copies

2022-02-15 Thread Nick Venenga
Nick Venenga added the comment: This script can reproduce the issue. The computer must be a Windows computer with volume shadow copy service enabled The computer must have shadow storage added to the drive being used This script changes the host machine by creating a shadow copy (permissions

[issue46763] os.path.samefile incorrect results for shadow copies

2022-02-15 Thread Nick Venenga
New submission from Nick Venenga : shutil.copy fails to copy a file from a shadow copy back to its original file since os.path.samefile returns True. os.path.samefile doesn't reliably detect these files are different since it relies on ino which is the same for both files >>> sc = >>>