6 ms·
Another problem: Windows support. Windows' file semantics are different and knowing when a file is closed becomes critical.
by epage 6y ago
Another problem: Windows support. Windows' file semantics are different and knowing when a file is closed becomes critical.
- gruez 6y agoElaborate?
- plorkyeran 6y agoBy default Windows locks a file while it is open and does not let you delete it. Other platforms do not, so code which naively reads and then deletes a file without explicitly closing it will work fine until you try to run it on Windows.
- Pxtl 6y agoUnclosed file handles are incredibly painful on Windows. The user can't edit or delete the file while it's in use and gets cryptic errors about it. There is no UI showing which process is holding the file handle. The standard practice on Windows when faced with a file that's got a stuck handle is to reboot.
- grenoire 6y agoWow, thank you for putting into writing one of my greatest pet peeves about Windows. Never thought about how often I encounter this issue until now, and how bad the UX is.
- Pxtl 6y agoHonestly, everything about the Explorer feels 2 decades behind he rest of Windows 10. Like, the rest of MS is has moved on, but their file browser is like an IE6-esque albatross. Everything makes it lock up.
- cameronbrown 6y agoExplorer is the only Windows 10 app that doesn't make me hate life. I'll take 2010 functionality over "metro" UI apps running in UWP anyday.
- Pxtl 6y agoI just wish it didn't lock the window at the slightest provocation. Connecting to a slow network share? Rclicked and one context extension is acting up? Just feeling cranky today? Well (not responding). And if you want to close the (not responding) window, I hope you didn't want any of your other windows, including you in-progress file copies.
- tenebrisalietum 6y agoWacko conspiracy theory: Microsoft really wants the end user completely separated and unaware of the file system so the user can't tell the difference between cloud and local files. This allows Microsoft to create dependency on its own cloud services, the government to have access to everyone's files, and laptop makers to cut down local storage significantly. Therefore Explorer is no longer going to get any love from Microsoft.
- jdxcode 6y agoIt’s because the file system doesn’t have inodes. It’s nothing to do with Explorer
- tenebrisalietum 6y agoI thought MFT indexes were the same as inodes.
- jdxcode 6y agoIn Unix files are pointers to pointers so you can have multiple files pointing the the same thing (hardline). You can’t do this in Windows and that’s also why you can’t delete in-use files or directories with files inside
- MauranKilom 6y agoRelevant xkcd: https://xkcd.com/1888/ https://xkcd.com/1888/
- ChrisSD 6y agoThat does depend how the file is opened. If it's opened with full file share rights (read/write/delete) then it won't block access. Delete is different in the sense that deleting a file is just adding a flag which tells the OS to delete the file once all file handles are closed. However newer versions of Windows 10 use POSIX delete semantics by default on NTFS. This means the file will be deleted immediately.
- skissane 6y ago> However newer versions of Windows 10 use POSIX delete semantics by default on NTFS. This means the file will be deleted immediately. Is that true? I thought POSIX deletion semantics only happened if FILE_DISPOSITION_POSIX_SEMANTICS is passed to SetFileInformationByHandle function (at FileDispositionInfoEx level), otherwise traditional Windows deletion semantics applied. (If POSIX semantics was the default, that might break legacy apps which were not expecting it – the kind of breaking change that Microsoft is usually careful to avoid.)
- ChrisSD 6y agoIf you use the DeleteFileW function then it handles all that for you, including setting FILE_DISPOSITION_POSIX_SEMANTICS. At least it did the last time I tested it. But sure, don't take my word for it. Test it. Edit: Just tested again. I'm not sure how you create files with FILE_SHARE_DELETE in Python so I used another program to create a file and hold the handle open. I then used `os.remove` to successfully delete the file while the handle was open. I could also delete the file from Windows Explorer. This was on Windows 10 1909 on the machine I use for development, thus it is possible that I've set some experimental option somewhere that affects Windows' behaviour. So further tests are welcome.
- skissane 6y agoOn further research, I believe you are correct. I am just surprised that Microsoft would change the default behaviour of DeleteFileW in a Windows 10 build. It seems like the kind of thing that would cause backward compatibility issues. Indeed, I've even found people reporting things breaking due to this [1]. Maybe Microsoft's culture doesn't put the same emphasis on backward compatibility that it used to? [1] https://stackoverflow.com/questions/60424732/did-the-behaviour-of-deleted-files-open-with-fileshare-delete-change-on-windows https://stackoverflow.com/questions/60424732/did-the-behavio...
- archgoon 6y ago> There is no UI showing which process is holding the file handle What about process explorer? https://docs.microsoft.com/en-us/sysinternals/downloads/process-explorer https://docs.microsoft.com/en-us/sysinternals/downloads/proc...
- rkagerer 6y agoOr Unlocker
- forrestthewoods 6y agoomg I had never heard of this tool. Thank you so much!
- afiori 6y agoFor a time Adobe Acrobat would automatically open all PDF files on all USB sticks on my computer. Since at the time moving PDFs around was my main reason to use USB sticks it didn't took long until I simply decided to remove Adobe Acrobat from my computer.
- jodrellblank 6y agoWhat are you all doing where deleting a file that’s in use is such a primary concern, or even at all desirable? I’ve had as much annoyance with files that have been “deleted” but are still using disk space (and still being used!) on Linux, as files that can’t be deleted because they’re in use on Windows. At least “can’t delete it because it’s in use” gives you a clue what’s going on, rather than a mystery amount of missing “free” disk space.