This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author nijave
Recipients nijave, paul.moore, steve.dower, tim.golden, zach.ware
Date 2022-02-16.01:45:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1644975913.58.0.577499491465.issue46763@roundup.psfhosted.org>
In-reply-to
Content
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 = pathlib.Path('//?/GLOBALROOT/Device/HarddiskVolumeShadowCopy3/test.file')
>>> o = pathlib.Path("V:/test.file")
>>> os.path.samefile(sc, o)
True
>>> os.stat(sc)
os.stat_result(st_mode=33206, st_ino=3458764513820579328, st_dev=1792739134, st_nlink=1, st_uid=0, st_gid=0, st_size=1, st_atime=1644973968, st_mtime=1644974052, st_ctime=1644973968)
>>> os.stat(o)
os.stat_result(st_mode=33206, st_ino=3458764513820579328, st_dev=1792739134, st_nlink=1, st_uid=0, st_gid=0, st_size=2, st_atime=1644973968, st_mtime=1644974300, st_ctime=1644973968)
>>> open(sc, "r").read()
'1'
>>> open(o, "r").read()
'12'

In the above example, you can see the shadow copy file and the original file. Their mode and ino are the same, but their modified time and contents are different
History
Date User Action Args
2022-02-16 01:45:13nijavesetrecipients: + nijave, paul.moore, tim.golden, zach.ware, steve.dower
2022-02-16 01:45:13nijavesetmessageid: <1644975913.58.0.577499491465.issue46763@roundup.psfhosted.org>
2022-02-16 01:45:13nijavelinkissue46763 messages
2022-02-16 01:45:13nijavecreate