[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 = 
>>> 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

--
components: Windows
messages: 413307
nosy: nijave, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: os.path.samefile incorrect results for shadow copies
type: behavior
versions: Python 3.9

___
Python tracker 
<https://bugs.python.org/issue46763>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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 to 
create shadow copies are required)

--
Added file: https://bugs.python.org/file50626/shadow-repro.py

___
Python tracker 
<https://bugs.python.org/issue46763>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com