Repository navigation
Fixing MoveItemToTrash behavior in Windows - #3337
Closed
tylergibson wants to merge 1 commit into
Closed
tylergibson wants to merge 1 commit into
tylergibson wants to merge 1 commit into
Conversation
tylergibson
force-pushed
the
FixMoveItemToTrash-Windows
branch
from
November 4, 2015 22:39
3a5b002 to
d10c245
Compare
Contributor
There was a problem hiding this comment.
nit: Your spacing is off here, relative to the methods that follow
Contributor
There was a problem hiding this comment.
Unless the style in this code is (void), it hasn't been used in C++ in a LONG time, also dtors by definition have no params, so saying void is redundant.
tylergibson
force-pushed
the
FixMoveItemToTrash-Windows
branch
from
November 4, 2015 22:45
d10c245 to
3af743b
Compare
Contributor
There was a problem hiding this comment.
nit: I would personally remove all the IDL annotation (/[in]/), it serves no real purpose here and adds noise (especially the ones like [string][unique][in])
tylergibson
force-pushed
the
FixMoveItemToTrash-Windows
branch
from
November 4, 2015 23:34
3af743b to
02c9f68
Compare
Contributor
Author
|
Thanks for the feedback Ryan, code updated for clarity and added smart pointers for leak safety :) |
tylergibson
force-pushed
the
FixMoveItemToTrash-Windows
branch
2 times, most recently
from
November 5, 2015 01:41
ad8d042 to
7f534e0
Compare
…moved to a drive's recycle bin before attempting to delete it.
tylergibson
force-pushed
the
FixMoveItemToTrash-Windows
branch
from
November 5, 2015 02:29
7f534e0 to
c7d92ab
Compare
zcbenz
pushed a commit
that referenced
this pull request
Nov 5, 2015
Modifying MoveItemToTrash for Windows to actually verify file can be moved to a drive's recycle bin before attempting to delete it. PR: #3337.
Contributor
|
It has been committed at 4ff5ce4, thanks! |
Contributor
|
@tylergibson @ryanmolden thanks so much for this 👍 |
7 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2715 by implementing IFileOperation (used in Windows Vista forward), replacing SHFileOperation. This allows us to do a filesystem PreDeleteItem check to ensure the file can actually go into the Recycle Bin. The existing behavior actually deletes files that cannot be recycled.
Before moving to IFileOperation, I attempted to extend the current implementation by adding the three checks (Type of Drive, Existence of Recycle Bin on that drive, and free space available in the Bin) with:
But these operations can be extremely slow, especially the SHQueryRecycleBin, which can take seconds to execute, locking the UI in the mean time. And there are still corner cases where this can fail.
So I move to reimplement with IFileOperation. It needs a full implementation of the interface IFileOperationProgressSink to be able to check Pre-Delete for the Recycle Bin. I authored the class implementation inline in platform_util_win.cc and only implemented the minimum methods required for MoveItemToTrash.
It may make sense to actually refactor the IFileOperationProgressSink class externally and use it more generally for other special case file I/O issues on Windows. SHFileOperation is still faster in execution, but has many limitations in use.
Behavior is now correct. Files that cannot be recycled will not be deleted and the function will return false.