A fast file manager for Windows and macOS that never freezes: tabs, dual panes, archives as folders, Quick Look-style previews. A File Explorer and Finder alternative written in Rust.
Rust archive-managerdesktop-appdual-paneexplorer-alternativefile-browserfile-explorerfile-managerfluent-designgpu-acceleratedgpuimacosmicaproductivityquick-lookrustrust-guitabswindowswindows-11windows-explorer
Deleting from the Recycle Bin asks once, not again in a window of Windows' own (870)
denfryf731124e2de0
diff --git a/crates/rf-win/src/fileops.rs b/crates/rf-win/src/fileops.rsindex d5e757fa..e19de892 100644--- a/crates/rf-win/src/fileops.rs+++ b/crates/rf-win/src/fileops.rs@@ -36,7 +36,7 @@ fn item(p: &Path) -> anyhow::Result<IShellItem> {}}-fn new_op(flags: u32) -> anyhow::Result<IFileOperation> {+pub(crate) fn new_op(flags: u32) -> anyhow::Result<IFileOperation> {ensure_com();let op: IFileOperation = unsafe { CoCreateInstance(&FileOperation, None, CLSCTX_ALL)? };unsafe { op.SetOperationFlags(FILEOPERATION_FLAGS(flags))? };diff --git a/crates/rf-win/src/recycle.rs b/crates/rf-win/src/recycle.rsindex 0c071f85..f47b2a94 100644--- a/crates/rf-win/src/recycle.rs+++ b/crates/rf-win/src/recycle.rs@@ -9,8 +9,8 @@ use windows::Win32::System::Variant::{PSTF_UTC, VARIANT, VariantToFileTime, Variuse windows::Win32::UI::Shell::{CMF_NORMAL, CMINVOKECOMMANDINFO, FOLDERID_RecycleBinFolder, IContextMenu, IEnumIDList, IShellFolder2,KF_FLAG_DEFAULT, SHBindToObject, SHCONTF_FOLDERS, SHCONTF_INCLUDEHIDDEN, SHCONTF_NONFOLDERS,- SEE_MASK_FLAG_NO_UI, SHEmptyRecycleBinW, SHERB_NOCONFIRMATION, SHERB_NOPROGRESSUI, SHERB_NOSOUND, SHGDN_FORPARSING, SHGDN_NORMAL,- SHGetKnownFolderIDList, SHQUERYRBINFO, SHQueryRecycleBinW, StrRetToBufW,+ SHEmptyRecycleBinW, SHERB_NOCONFIRMATION, SHERB_NOPROGRESSUI, SHERB_NOSOUND, SHGDN_FORPARSING, SHGDN_NORMAL,+ FOF_NOCONFIRMATION, FOF_NOERRORUI, SHCreateShellItemArray, SHGetKnownFolderIDList, SHQUERYRBINFO, SHQueryRecycleBinW, StrRetToBufW,};use windows::Win32::UI::WindowsAndMessaging::{CreatePopupMenu, DestroyMenu, SW_SHOWNORMAL};use windows::core::{GUID, PCSTR, PCWSTR, s};@@ -340,10 +340,9 @@ fn find_by_keys(folder: &IShellFolder2, wanted: &[String]) -> anyhow::Result<VecOk(found)}-/// Deletes exactly the items whose keys are given, for good, by invoking the bin's own "delete" verb on their ID lists-/// (the same route as [`restore`] takes with "undelete"). The verb is the bin's, so it removes the item's `$R` data and `$I`-/// record together, and its scope is the list of ID lists handed to `GetUIObjectOf`, which are only those found by key.-/// No keys, or none found: an error, nothing is invoked. NOT RUN against a real bin by the author; see docs/design/recycle-bin.md.+/// Deletes exactly the items whose keys are given, for good: the shell's file engine deletes the bin's own items (built from the+/// bin's ID list and theirs), so the item's `$R` data and `$I` record go together, and its scope is only the items found by key.+/// No keys, or none found: an error, nothing is deleted.pub fn delete_by_keys(keys: &[String]) -> anyhow::Result<()> {anyhow::ensure!(!keys.is_empty(), "no items to delete");refuse_without_shell(crate::engine_guard::Op::DeleteFromBin)?;@@ -351,28 +350,19 @@ pub fn delete_by_keys(keys: &[String]) -> anyhow::Result<()> {let found = find_by_keys(&folder, keys)?;anyhow::ensure!(!found.is_empty(), "Öğeler Geri Dönüşüm Kutusu'nda bulunamadı");anyhow::ensure!(found.len() <= keys.len(), "more items matched than were asked for");+ // Through the shell's file engine, told not to ask: our own dialog has asked already. The bin's "delete" verb asked again in a+ // window of its own whatever the flags said (seen 2026-12-03: SEE_MASK_FLAG_NO_UI did not keep it away), with no owner, so it+ // could open behind rustyfiles and look like an empty, frozen dialog (issue 870). The engine's progress belongs to our window.unsafe {- let raw: Vec<*const ITEMIDLIST> = found.iter().map(|p| p.0 as *const _).collect();- let cm: IContextMenu = folder.GetUIObjectOf(HWND::default(), &raw, None)?;- let menu = CreatePopupMenu()?;- let res = (|| -> anyhow::Result<()> {- cm.QueryContextMenu(menu, 0, 1, 0x7FFF, CMF_NORMAL).ok()?;- let info = CMINVOKECOMMANDINFO {- cbSize: std::mem::size_of::<CMINVOKECOMMANDINFO>() as u32,- // our own dialog has asked already: the shell is not to ask again (CMIC_MASK_FLAG_NO_UI is SEE_MASK_FLAG_NO_UI).- // How the bin's verb treats this flag is NOT known (skip its question, or refuse because it cannot ask): with- // RUSTYFILES_BIN_DELETE_SHELL_UI=1 the flag is left out, so that the first live run can try both without a rebuild.- fMask: if std::env::var_os("RUSTYFILES_BIN_DELETE_SHELL_UI").is_some_and(|v| v == "1") { 0 } else { SEE_MASK_FLAG_NO_UI },- lpVerb: PCSTR(s!("delete").as_ptr()),- nShow: SW_SHOWNORMAL.0,- ..Default::default()- };- cm.InvokeCommand(&info)?;- Ok(())- })();- let _ = DestroyMenu(menu);- res+ let root = Pidl(SHGetKnownFolderIDList(&FOLDERID_RecycleBinFolder, KF_FLAG_DEFAULT.0 as u32, None)?);+ let children: Vec<*const ITEMIDLIST> = found.iter().map(|p| p.0 as *const _).collect();+ let items = SHCreateShellItemArray(Some(root.0), None, Some(&children))?;+ let op = crate::fileops::new_op(FOF_NOCONFIRMATION.0 | FOF_NOERRORUI.0)?;+ op.DeleteItems(&items)?;+ op.PerformOperations()?;+ anyhow::ensure!(!op.GetAnyOperationsAborted()?.as_bool(), "the deletion was cancelled");}+ Ok(())}/// [`rf_core::recycle_bin::BinBackend`] on the real bin. Both calls go through the shell thread ([`crate::sta::call`]).@@ -451,6 +441,33 @@ mod tests {let _ = std::fs::remove_dir_all(&root);}+ /// Hundreds of items deleted from the bin as the page does, with no second question from the shell (issue 870: the verb asked+ /// again and waited for a click; this route ends in well under a second). Changes the user's bin (its own files go in and out),+ /// so it runs only when asked: `cargo test -p rf-win --lib many_deleted_from_the_bin -- --ignored --nocapture`.+ #[test]+ #[ignore]+ fn many_deleted_from_the_bin_at_once() {+ let root = std::env::temp_dir().join(format!("rf-binmany-{}", std::process::id()));+ let _ = std::fs::remove_dir_all(&root);+ std::fs::create_dir_all(&root).unwrap();+ let tag = format!("rf-binmany-{}-", std::process::id());+ let files: Vec<std::path::PathBuf> = (0..300).map(|i| root.join(format!("{tag}{i}.txt"))).collect();+ for f in &files {+ std::fs::write(f, b"x").unwrap();+ }+ crate::fileops::delete(&files, false).unwrap();+ let all = list().unwrap();+ let keys: Vec<String> = all.iter().filter(|i| i.name.starts_with(&tag)).map(|i| rf_core::recycle_bin::key_of(&i.parsing_path)).collect();+ eprintln!("{} in the bin, {} of them ours; deleting", all.len(), keys.len());+ let t = std::time::Instant::now();+ let r = rf_core::recycle_bin::BinBackend::delete_keys(&ShellBin, &keys);+ eprintln!("delete_keys: {r:?} after {:?}", t.elapsed());+ let after = list().unwrap();+ eprintln!("{} in the bin after", after.len());+ let _ = std::fs::remove_dir_all(&root);+ assert_eq!(after.iter().filter(|i| i.name.starts_with(&tag)).count(), 0);+ }+#[test]fn items_are_put_back_without_the_shell_and_missing_ones_are_counted() {let root = std::env::temp_dir().join(format!("rf-restore-{}", std::process::id()));diff --git a/docs/design/recycle-bin.md b/docs/design/recycle-bin.mdindex cf9b336d..9ad67b0a 100644--- a/docs/design/recycle-bin.md+++ b/docs/design/recycle-bin.md@@ -39,13 +39,10 @@ them: every one is a new menu entry, button or field, and nothing runs at start-* A row shows the shell's own icon for the item's stored copy (`$R...` keeps the extension, so a zip gets the zip icon), through theshared icon cache the folder list uses; the glyph (tinted as in the folder list) is drawn until the icon has arrived.-**Not run:** the real `delete` verb on a real bin (the rule was never to delete anything in the user's real bin). What is-unknown: how the bin's verb treats `SEE_MASK_FLAG_NO_UI`. Three outcomes are possible: it skips its own "are you sure" (what we-want); it ignores the flag and asks (a second question, shown by the shell with no owner window, so it may sit behind the app);-or it refuses because it may not ask (every deletion then ends as "N öğe silinemedi": a safe failure, but the feature does-nothing). The environment variable `RUSTYFILES_BIN_DELETE_SHELL_UI=1` leaves the flag out, so the first live run can try both-without a rebuild. Also unknown: whether a failure of one item (in use) makes the verb return an error or silently skip it (both are-handled: the report counts what is left).+**Run (2026-12-03, issue 870):** the bin's `delete` verb IGNORES `SEE_MASK_FLAG_NO_UI` and asks again in a window of its own, with+no owner, so it may sit behind the app (the report: "an empty dialog, frozen"). The deletion now goes through the shell's file engine+(`IFileOperation::DeleteItems` on the bin's own items, `FOF_NOCONFIRMATION`), owned by the app's window like every other file+operation: our dialog is the only question. A failure of one item (in use) is counted by the report from what is left.## (b) The bin's own settings