Skip to content
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

feat: check for operation abort #113

Merged
merged 1 commit into from
Aug 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ impl TrashContext {
pfo.DeleteItem(&shi, None)?;
}
pfo.PerformOperations()?;

// https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-ifileoperation-performoperations
// this method can still return a success code. Use the GetAnyOperationsAborted method to determine if this was the case.
if pfo.GetAnyOperationsAborted()?.as_bool() {
// TODO: return the reason why the operation was aborted.
// We may retrieve reason from the IFileOperationProgressSink but
// the list of HRESULT codes is not documented.
return Err(Error::Unknown { description: "Some operations were aborted".into() });
}
Ok(())
}
}
Expand Down
Loading