Eryk Sun <[email protected]> added the comment:
> Explorer keeps handles open to directories to get updates via
> ReadDirectoryChangesExW. It opens watched directories with
> shared delete access, so deleting the child succeeds. But as
> discussed above, the directory isn't unlinked from the parent
> until Explorer closes its handle.
In Windows 10, NTFS allows deleting an empty directory that's currently opened
with shared-delete access, so this race condition will be increasingly less
common. For example:
access = GENERIC_READ
sharing = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE
disposition = OPEN_EXISTING
flags = FILE_FLAG_BACKUP_SEMANTICS
os.mkdir('spam')
h = CreateFile('spam', access, sharing, None, disposition, flags, None)
os.rmdir('spam')
>>> print(GetFinalPathNameByHandle(h, 0))
\\?\C:\$Extend\$Deleted\004E00000000632F70819337
FAT filesystems do not support this capability, and may never support it, so
the problem hasn't gone away completely.
----------
versions: +Python 3.10, Python 3.9 -Python 3.6, Python 3.7
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue33240>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com