Message 388964 - Python tracker

Message388964

Author eryksun
Recipients Ofekmeister, eryksun, giampaolo.rodola, paul.moore, steve.dower, tarek, tim.golden, yuliu, zach.ware
Date 2021-03-17.20:34:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1616013249.13.0.810695243275.issue33240@roundup.psfhosted.org>
In-reply-to
Content
> 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.
History
Date User Action Args
2021-03-17 20:34:09eryksunsetrecipients: + eryksun, paul.moore, giampaolo.rodola, tim.golden, tarek, zach.ware, steve.dower, Ofekmeister, yuliu
2021-03-17 20:34:09eryksunsetmessageid: <1616013249.13.0.810695243275.issue33240@roundup.psfhosted.org>
2021-03-17 20:34:09eryksunlinkissue33240 messages
2021-03-17 20:34:08eryksuncreate