-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Windows backend can really delete files in some conditions #28
Comments
Hi, Thanks in advance |
Recovery tools may still be able to help: deleting a file doesn't usually overwrite the data, it just marks the area as not in use. So recovery tools work by scanning 'empty' disk space for data that looks like files. But it involves a degree of luck: once the disk space is marked as empty, a new file could be written in that space, which replaces the old data. And I don't know enough about recovery tools to help you with them. |
I started looking into IFileOperation due to another issue, and was able to get it working. I am not sure what the best way to implement the check for the delete actually working (as not sure how to setup a test scenario). I was able to get the IFileOperationSink, which appears to at least be partially involved in some of those links on how to handle this, to work as well. All of this was using pywin32 to interface to IFileOperation. Still some work to be done. |
Looks like IFileOperationSink is at least the answer, I noticed Qt 5.15 also picked up a cross platform trash/recycle interface. It looks like they have used this to prevent deletion https://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/io/qfilesystemengine_win.cpp#n493. I will be making a PR to adapt that for the IFileOperation version (currently for Vista and newer and requires pywin32). |
Have confirmed in recent work that IFileOperationSink can detect when the file would be deleted, but I was not able to get it to stop the operation. I need to look into it a bit more. |
This is a follow up to an issue opened on Jupyter: jupyter/notebook#3631
send2trash on Windows uses the
SHFileOperation
interface with theFOF_ALLOWUNDO
flag to move files to the recycle bin. However, the Windows docs only say that this means "Preserve undo information, if possible", and a couple of SO questions seem to confirm that that means files may be properly deleted in some conditions:In particular, it seems that there may be a maximum percentage of disk space for the recycle bin, and deleting files bigger than the available space might cause them to be really deleted. This is a pretty important caveat!
The second of those SO questions and this linked codeguru thread mentions a few possible ways around this, none of them great:
So I've no idea what should happen, but I thought it was worth opening an issue here about it.
The text was updated successfully, but these errors were encountered: