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
An indexed external disk without a change journal can be ejected: the index lets go of it (622)
gelenmedyaac404d42dae2
diff --git a/crates/rf-app/src/workspace.rs b/crates/rf-app/src/workspace.rsindex 7c64bfbd..4b4256f5 100644--- a/crates/rf-app/src/workspace.rs+++ b/crates/rf-app/src/workspace.rs@@ -415,6 +415,8 @@ pub fn on_drive(path: &std::path::Path, letter: char) -> bool {/// window lets go of it — panes on that drive go Home (their folder watchers, size walks and/// listings stop), its previews close, queued thumbnails are dropped.pub fn release_drive(letter: char, cx: &mut App) {+ // the name index too: a drive with no change journal (exFAT) is followed with a watcher on its root, which held it (issue 622)+ rf_win::indexer::release_drive(letter);let list = cx.try_global::<OpenWorkspaces>().map(|g| g.0.clone()).unwrap_or_default();for (handle, ws) in list {let Some(ws) = ws.upgrade() else { continue };diff --git a/crates/rf-win/examples/holders_probe.rs b/crates/rf-win/examples/holders_probe.rsnew file mode 100644index 00000000..37221794--- /dev/null+++ b/crates/rf-win/examples/holders_probe.rs@@ -0,0 +1,16 @@+//! What keeps a drive "in use": every open file, folder and volume handle on it, by process.+//! `cargo run -p rf-win --example holders_probe -- D`+//!+//! Lists the processes this one may look into (the user's own); the ones it may not (the system's, an elevated program, an+//! antivirus) are named at the end, since one of them may be the holder. Reads only; nothing is closed or asked to let go.++fn main() {+ let letter = std::env::args().nth(1).and_then(|a| a.chars().next()).unwrap_or('C');+ let (lines, closed) = rf_win::holders::all_handles_on(letter);+ println!("{} handle(s) on {}: in the processes that could be looked into", lines.len(), letter.to_ascii_uppercase());+ for l in &lines {+ println!(" {l}");+ }+ println!("{} process(es) could not be looked into:", closed.len());+ println!(" {}", closed.join(", "));+}diff --git a/crates/rf-win/src/holders.rs b/crates/rf-win/src/holders.rsindex 73b48df3..18ef6220 100644--- a/crates/rf-win/src/holders.rs+++ b/crates/rf-win/src/holders.rs@@ -17,15 +17,19 @@use std::ffi::c_void;use windows::Win32::Foundation::{CloseHandle, DUPLICATE_SAME_ACCESS, DuplicateHandle, HANDLE};-use windows::Win32::Storage::FileSystem::{FILE_NAME_NORMALIZED, FILE_TYPE_DISK, GetFileType, GetFinalPathNameByHandleW};+use windows::Win32::Storage::FileSystem::{FILE_NAME_NORMALIZED, FILE_TYPE_DISK, GetFileType, GetFinalPathNameByHandleW, QueryDosDeviceW};use windows::Win32::System::Diagnostics::ToolHelp::{CreateToolhelp32Snapshot, PROCESSENTRY32W, Process32FirstW, Process32NextW, TH32CS_SNAPPROCESS};use windows::Win32::System::Threading::{GetCurrentProcess, OpenProcess, PROCESS_DUP_HANDLE};#[link(name = "ntdll")]unsafe extern "system" {fn NtQuerySystemInformation(class: u32, info: *mut c_void, len: u32, returned: *mut u32) -> i32;+ fn NtQueryObject(handle: *mut c_void, class: u32, info: *mut c_void, len: u32, returned: *mut u32) -> i32;}+/// `ObjectNameInformation`.+const OBJECT_NAME: u32 = 1;+/// `SystemExtendedHandleInformation`.const HANDLES_CLASS: u32 = 64;/// `STATUS_INFO_LENGTH_MISMATCH`: the buffer was too small.@@ -55,11 +59,43 @@ fn skipped(access: u32) -> bool {/// The lines for the log: what each of rustyfiles' processes holds open on drive `letter`. Empty when nothing is held by us.pub fn own_handles_on(letter: char) -> Vec<String> {let prefix = format!(r"\\?\{}:", letter.to_ascii_uppercase());- handles_of(&our_processes(), &prefix)+ handles_of(&processes(true), &prefix, volume_device(letter).as_deref()).0+}++/// The same for EVERY process this one may look into, for a measurement by hand (`examples/holders_probe`): the lines, and the+/// names of the processes that could not be looked into (another user's, the system's, an elevated one).+pub fn all_handles_on(letter: char) -> (Vec<String>, Vec<String>) {+ let prefix = format!(r"\\?\{}:", letter.to_ascii_uppercase());+ handles_of(&processes(false), &prefix, volume_device(letter).as_deref())+}++/// The kernel's name of drive `letter`'s volume (`\Device\HarddiskVolume7`).+fn volume_device(letter: char) -> Option<String> {+ let name = crate::wide::wide(format!("{}:", letter.to_ascii_uppercase()));+ let mut buf = [0u16; 512];+ // SAFETY: the name is a NUL-ended string that lives through the call; the buffer's length is its own+ let n = unsafe { QueryDosDeviceW(windows::core::PCWSTR(name.as_ptr()), Some(&mut buf)) } as usize;+ (n > 0).then(|| crate::wide::from_wide(&buf))+}++/// The kernel's name of what a handle is open on. Asked only of a disk file's handle (see the top of this file about pipes).+fn object_name(h: HANDLE) -> Option<String> {+ let mut buf = vec![0u16; 2048];+ let mut got = 0u32;+ // SAFETY: the buffer is 4096 bytes and the call is told so; it writes a UNICODE_STRING (length in bytes, a pointer into the+ // same buffer) followed by the letters+ let status = unsafe { NtQueryObject(h.0, OBJECT_NAME, buf.as_mut_ptr() as *mut c_void, (buf.len() * 2) as u32, &mut got) };+ if status < 0 {+ return None;+ }+ let bytes = buf[0] as usize;+ // (the header is 16 bytes on a 64-bit system: two lengths, padding, the pointer)+ let first = 16 / 2;+ (bytes > 0 && first + bytes / 2 <= buf.len()).then(|| String::from_utf16_lossy(&buf[first..first + bytes / 2]))}-/// (process id, image name) of every running program of ours.-fn our_processes() -> Vec<(u32, String)> {+/// (process id, image name) of every running program: of ours only, or of all.+fn processes(ours: bool) -> Vec<(u32, String)> {let mut out = Vec::new();// SAFETY: the snapshot handle is used and closed here; `dwSize` is set as the API asks.unsafe {@@ -68,7 +104,7 @@ fn our_processes() -> Vec<(u32, String)> {let mut more = Process32FirstW(snap, &mut e).is_ok();while more {let name = crate::wide::from_wide(&e.szExeFile);- if OURS.iter().any(|o| name.eq_ignore_ascii_case(o)) {+ if !ours || OURS.iter().any(|o| name.eq_ignore_ascii_case(o)) {out.push((e.th32ProcessID, name));}more = Process32NextW(snap, &mut e).is_ok();@@ -79,13 +115,16 @@ fn our_processes() -> Vec<(u32, String)> {}/// The disk files the given processes hold open whose path begins with `prefix` (compared without regard to case), one line each:-/// `name (pid): path [access]`.-fn handles_of(processes: &[(u32, String)], prefix: &str) -> Vec<String> {+/// `name (pid): path [access]`. A handle on the volume itself (`device`: opened as `\\.\D:`, as a program does to read the change+/// journal or the disk's layout) has no path and is named as that: it keeps a drive from being removed just the same, and was+/// invisible here until 2026-12-05. The second list: the processes that could not be opened.+pub(crate) fn handles_of(processes: &[(u32, String)], prefix: &str, device: Option<&str>) -> (Vec<String>, Vec<String>) {let mut lines = Vec::new();+ let mut closed = Vec::new();if processes.is_empty() {- return lines;+ return (lines, closed);}- let Some(table) = handle_table() else { return lines };+ let Some(table) = handle_table() else { return (lines, closed) };// SAFETY: `table` holds what the system wrote: a count, a reserved word, then that many entries; the count is checked against// the buffer's length before an entry is read.let count = unsafe { *(table.as_ptr() as *const usize) };@@ -96,7 +135,10 @@ fn handles_of(processes: &[(u32, String)], prefix: &str) -> Vec<String> {let me = unsafe { GetCurrentProcess() };for (pid, name) in processes {// SAFETY: a handle to one of our own processes, closed below- let Ok(process) = (unsafe { OpenProcess(PROCESS_DUP_HANDLE, false, *pid) }) else { continue };+ let Ok(process) = (unsafe { OpenProcess(PROCESS_DUP_HANDLE, false, *pid) }) else {+ closed.push(format!("{name} ({pid})"));+ continue;+ };for i in 0..count {// SAFETY: `i < count`, and `count` entries lie inside the buffer (checked above); read unaligned, as a byte buffer giveslet e = unsafe { std::ptr::read_unaligned(table.as_ptr().add(first + i * size) as *const Entry) };@@ -118,6 +160,11 @@ fn handles_of(processes: &[(u32, String)], prefix: &str) -> Vec<String> {if path.to_lowercase().starts_with(&prefix) {lines.push(format!("{name} ({pid}): {path} [{}]", what(e.access)));}+ } else if n == 0+ && let Some(device) = device+ && object_name(copy).is_some_and(|o| o.eq_ignore_ascii_case(device))+ {+ lines.push(format!("{name} ({pid}): the volume itself, opened as a device [access {:#010x}]", e.access));}}let _ = CloseHandle(copy);@@ -128,7 +175,7 @@ fn handles_of(processes: &[(u32, String)], prefix: &str) -> Vec<String> {let _ = CloseHandle(process);}}- lines+ (lines, closed)}/// What a handle's access rights say it is for, in words (with the number).@@ -176,15 +223,32 @@ mod tests {let held = std::fs::File::open(&file).unwrap();let me = [(std::process::id(), "this test".to_string())];let prefix = format!(r"\\?\{}", std::fs::canonicalize(&dir).unwrap().to_string_lossy().trim_start_matches(r"\\?\"));- let lines = handles_of(&me, &prefix);+ let (lines, _) = handles_of(&me, &prefix, None);assert!(lines.iter().any(|l| l.starts_with("this test (") && l.to_lowercase().contains("held.txt")), "{lines:?}");drop(held);- let lines = handles_of(&me, &prefix);+ let (lines, _) = handles_of(&me, &prefix, None);assert!(!lines.iter().any(|l| l.to_lowercase().contains("held.txt")), "{lines:?}");- assert!(handles_of(&me, r"\\?\Q:\no such place").is_empty());+ assert!(handles_of(&me, r"\\?\Q:\no such place", None).0.is_empty());let _ = std::fs::remove_dir_all(&dir);}+ /// A program that opens the volume itself (the change journal's readers do) holds the drive as much as an open file does.+ #[test]+ fn a_volume_opened_as_a_device_is_listed_too() {+ let letter = std::env::temp_dir().to_string_lossy().chars().next().unwrap();+ let device = volume_device(letter).expect("the temp folder's drive has a device name");+ assert!(device.starts_with(r"\Device\"), "{device}");+ // (opened with no access rights asked: allowed to any user, and it is the object that counts here)+ use std::os::windows::fs::OpenOptionsExt;+ let Ok(volume) = std::fs::OpenOptions::new().access_mode(0).share_mode(7).open(format!(r"\\.\{letter}:")) else { return };+ let me = [(std::process::id(), "this test".to_string())];+ let (lines, _) = handles_of(&me, &format!(r"\\?\{letter}:"), Some(&device));+ assert!(lines.iter().any(|l| l.contains("the volume itself")), "{lines:?}");+ drop(volume);+ let (lines, _) = handles_of(&me, &format!(r"\\?\{letter}:"), Some(&device));+ assert!(!lines.iter().any(|l| l.contains("the volume itself")), "{lines:?}");+ }+#[test]fn pipes_access_masks_are_left_alone_and_file_ones_are_named() {assert!(skipped(0x0012_019f));diff --git a/crates/rf-win/src/indexer.rs b/crates/rf-win/src/indexer.rsindex 43c98356..d38c7d95 100644--- a/crates/rf-win/src/indexer.rs+++ b/crates/rf-win/src/indexer.rs@@ -49,6 +49,93 @@ struct Slot {cloud: bool,/// A re-walk of a network root is running on a thread of its own.rescanning: AtomicBool,+ /// The folder of the saved indexes: changes in it are not the root's.+ ignore: PathBuf,+ /// The recursive watcher on the root (none on a journaled root), and since when the root is let go of ([`release_drive`]).+ hold: Mutex<Hold>,+}++#[derive(Default)]+struct Hold {+ watcher: Option<notify::RecommendedWatcher>,+ released: Option<Instant>,+}++/// How long a root that was let go of for an eject is left alone before it is watched again, if it is still there.+const RELEASE_GRACE: Duration = Duration::from_secs(20);++/// A recursive watcher on the slot's root that collects the folders something changed in. The watcher holds the root's folder+/// open for as long as it lives.+fn watch(slot: &Arc<Slot>) -> Option<notify::RecommendedWatcher> {+ // (weak: the watcher is kept in the slot itself)+ let weak = Arc::downgrade(slot);+ let made = notify::recommended_watcher(move |res: notify::Result<notify::Event>| {+ let Ok(ev) = res else { return };+ if matches!(ev.kind, notify::EventKind::Access(_)) {+ return;+ }+ let Some(slot) = weak.upgrade() else { return };+ let mut d = slot.dirty.lock();+ for p in ev.paths {+ if p.starts_with(&slot.ignore) {+ continue;+ }+ if let Some(parent) = p.parent() {+ d.insert(parent.to_path_buf());+ }+ }+ });+ match made {+ Ok(mut w) => match w.watch(&slot.root, RecursiveMode::Recursive) {+ Ok(()) => Some(w),+ Err(e) => {+ log::info!("indexer: no watch on {}: {e}", slot.root.display());+ None+ }+ },+ Err(e) => {+ log::info!("indexer: watcher: {e}");+ None+ }+ }+}++/// Whether `root` is on drive `letter` (`D:\...`).+fn on_drive(root: &Path, letter: char) -> bool {+ let s = root.to_string_lossy();+ let mut c = s.chars();+ c.next().is_some_and(|l| l.eq_ignore_ascii_case(&letter)) && c.next() == Some(':')+}++/// Lets go of every indexed root on drive `letter`, for an eject: the watcher on it is closed and the root is left alone until it+/// has stayed for [`RELEASE_GRACE`] (then it is watched again and walked once the PC is idle, as what changed meanwhile was not+/// seen). Gives the number of roots let go of.+///+/// WHY (issue 622, measured on 2026-12-05 on an external SSD formatted exFAT: `holders_probe` and the log of a failed eject both+/// showed this process holding `\\?\D:\` as "a folder being watched"). A volume with no change journal (exFAT, FAT32) is followed+/// with a recursive watcher on its root, which keeps the root open for good. A tab on the drive goes Home when the drive is to be+/// removed; this watcher did not hear of it, so an indexed external disk without a journal could never be ejected while+/// rustyfiles ran, from its own sidebar or from Windows. Not covered: a walk of the drive that is running at that moment (it+/// holds folders open until it ends).+pub fn release_drive(letter: char) -> usize {+ let slots: Vec<Arc<Slot>> = service().lock().as_ref().map(|s| s.slots.clone()).unwrap_or_default();+ let mut n = 0;+ for slot in slots.iter().filter(|s| !s.journaled && !s.network && on_drive(&s.root, letter)) {+ release(slot);+ n += 1;+ log::info!("indexer: {} is let go of for an eject", slot.root.display());+ }+ n+}++fn release(slot: &Slot) {+ let watcher = {+ let mut h = slot.hold.lock();+ h.released = Some(Instant::now());+ h.watcher.take()+ };+ // (dropped outside the lock: closing it waits for its thread)+ drop(watcher);}/// How long nobody has touched the keyboard or mouse before a walk that can wait starts: a walk reads the whole drive (minutes and@@ -94,7 +181,6 @@ fn wait_until_idle(root: &Path, cancel: &AtomicBool) -> bool {struct Service {slots: Vec<Arc<Slot>>,cancel: Arc<AtomicBool>,- _watchers: Vec<notify::RecommendedWatcher>,}static SERVICE: OnceLock<Mutex<Option<Service>>> = OnceLock::new();@@ -114,7 +200,6 @@ pub fn start(roots: Vec<PathBuf>, dir: PathBuf) {let _ = std::fs::create_dir_all(&dir);let cancel = Arc::new(AtomicBool::new(false));let mut slots = Vec::new();- let mut watchers = Vec::new();for root in roots {let journaled = crate::usn::query(&root).is_some();let spinning = crate::drives::seek_penalty(&root) == Some(true);@@ -132,6 +217,8 @@ pub fn start(roots: Vec<PathBuf>, dir: PathBuf) {network,cloud,rescanning: AtomicBool::new(false),+ ignore: dir.clone(),+ hold: Mutex::new(Hold::default()),});// NTFS: the change journal says which folders changed, once a second (cheaper than a// watcher on a whole drive, which a build floods with events, and it can't overflow)@@ -141,39 +228,14 @@ pub fn start(roots: Vec<PathBuf>, dir: PathBuf) {}// changed folders, collected from the start (a walk running meanwhile misses nothing:// the fresh index is refreshed with them once it's swapped in)- let s2 = slot.clone();- let ignore = dir.clone();- match notify::recommended_watcher(move |res: notify::Result<notify::Event>| {- let Ok(ev) = res else { return };- if matches!(ev.kind, notify::EventKind::Access(_)) {- return;- }- let mut d = s2.dirty.lock();- for p in ev.paths {- if p.starts_with(&ignore) {- continue;- }- if let Some(parent) = p.parent() {- d.insert(parent.to_path_buf());- }- }- }) {- Ok(mut w) => {- if let Err(e) = w.watch(&slot.root, RecursiveMode::Recursive) {- log::info!("indexer: no watch on {}: {e}", slot.root.display());- } else {- watchers.push(w);- }- }- Err(e) => log::info!("indexer: watcher: {e}"),- }+ slot.hold.lock().watcher = watch(&slot);slots.push(slot);}for slot in &slots {let (slot, cancel) = (slot.clone(), cancel.clone());let _ = std::thread::Builder::new().name("rf-indexer".into()).spawn(move || run(slot, cancel));}- *service().lock() = Some(Service { slots, cancel, _watchers: watchers });+ *service().lock() = Some(Service { slots, cancel });}/// Stops indexing (the indexes are dropped; saved files stay).@@ -181,6 +243,9 @@ pub fn stop() {if let Some(s) = service().lock().take() {s.cancel.store(true, Ordering::Relaxed);for slot in &s.slots {+ // (the watcher's callback only holds the slot weakly, but the slot holds the watcher: let it go here)+ let watcher = slot.hold.lock().watcher.take();+ drop(watcher);save(slot);}}@@ -283,6 +348,43 @@ fn follow(slot: Arc<Slot>, cancel: &Arc<AtomicBool>) {let mut seen = crate::usn::query(&slot.root).map(|j| j.next);while !cancel.load(Ordering::Relaxed) {std::thread::sleep(Duration::from_secs(1));+ // let go of for an eject ([`release_drive`]): nothing on the drive is touched until it has stayed past the grace time; then+ // it is watched again, and walked again once the PC is idle (what changed meanwhile was not seen)+ let released = slot.hold.lock().released;+ if let Some(since) = released {+ if since.elapsed() < RELEASE_GRACE || !slot.root.exists() {+ continue;+ }+ let again = watch(&slot);+ let stayed = {+ let mut h = slot.hold.lock();+ // (let go of again while the watcher was being made: it stays let go of, and this watcher is dropped)+ let same = h.released == Some(since);+ if same {+ h.released = None;+ h.watcher = again;+ }+ same+ };+ if !stayed {+ continue;+ }+ log::info!("indexer: {} stayed: watched again", slot.root.display());+ if !slot.rescanning.swap(true, Ordering::Relaxed) {+ let (s2, c2) = (slot.clone(), cancel.clone());+ let _ = std::thread::Builder::new().name("rf-indexer".into()).spawn(move || {+ if wait_until_idle(&s2.root, &c2) && s2.hold.lock().released.is_none() {+ let fresh = Index::build(&s2.root, &c2);+ if !c2.load(Ordering::Relaxed) && !fresh.is_empty() && s2.hold.lock().released.is_none() {+ *s2.index.write() = Some(fresh);+ s2.changed_since_save.store(true, Ordering::Relaxed);+ save(&s2);+ }+ }+ s2.rescanning.store(false, Ordering::Relaxed);+ });+ }+ }let now = crate::usn::query(&slot.root).map(|j| j.next);let dirs: Vec<PathBuf> = slot.dirty.lock().drain().collect();if !dirs.is_empty() {@@ -487,6 +589,63 @@ fn follow_journal(slot: &Slot, cancel: &AtomicBool) {mod tests {use super::*;+ fn plain_slot(root: &Path, dir: &Path) -> Arc<Slot> {+ Arc::new(Slot {+ root: root.to_path_buf(),+ file: file_for(dir, root),+ index: RwLock::new(None),+ state: AtomicU8::new(State::Ready as u8),+ dirty: Mutex::new(HashSet::new()),+ changed_since_save: AtomicBool::new(false),+ journaled: false,+ spinning: false,+ network: false,+ cloud: false,+ rescanning: AtomicBool::new(false),+ ignore: dir.to_path_buf(),+ hold: Mutex::new(Hold::default()),+ })+ }++ /// Issue 622: the watcher on a root without a change journal holds the root open; let go of for an eject, the handle is gone.+ #[test]+ fn a_root_let_go_of_for_an_eject_is_no_longer_held_open() {+ let base = std::fs::canonicalize(std::env::temp_dir()).unwrap().join(format!("rf-indexer-release-{}", std::process::id()));+ let (root, dir) = (base.join("root"), base.join("saved"));+ std::fs::create_dir_all(&root).unwrap();+ std::fs::create_dir_all(&dir).unwrap();+ let slot = plain_slot(&root, &dir);+ slot.hold.lock().watcher = watch(&slot);+ assert!(slot.hold.lock().watcher.is_some(), "a folder of the temp folder can be watched");+ let me = [(std::process::id(), "this test".to_string())];+ let prefix = format!(r"\\?\{}", root.to_string_lossy().trim_start_matches(r"\\?\"));+ let held = || crate::holders::handles_of(&me, &prefix, None).0.iter().any(|l| l.contains("watched or listed"));+ assert!(held(), "the watcher holds the root: {:?}", crate::holders::handles_of(&me, &prefix, None).0);+ // a change is still collected (the watcher's callback reaches the slot)+ std::fs::write(root.join("new.txt"), b"x").unwrap();+ let until = Instant::now() + Duration::from_secs(3);+ while slot.dirty.lock().is_empty() && Instant::now() < until {+ std::thread::sleep(Duration::from_millis(20));+ }+ assert!(!slot.dirty.lock().is_empty(), "a new file marks its folder");+ release(&slot);+ assert!(slot.hold.lock().released.is_some() && slot.hold.lock().watcher.is_none());+ let until = Instant::now() + Duration::from_secs(3);+ while held() && Instant::now() < until {+ std::thread::sleep(Duration::from_millis(20));+ }+ assert!(!held(), "the root is let go of: {:?}", crate::holders::handles_of(&me, &prefix, None).0);+ let _ = std::fs::remove_dir_all(&base);+ }++ #[test]+ fn a_root_is_told_from_its_drive_letter() {+ assert!(on_drive(Path::new(r"D:\"), 'd'));+ assert!(on_drive(Path::new(r"d:\photos"), 'D'));+ assert!(!on_drive(Path::new(r"E:\"), 'D'));+ assert!(!on_drive(Path::new(r"\\nas\share"), 'n'));+ }+fn drive(kind: crate::drives::DriveKind, fs: &str, external: bool) -> crate::drives::Drive {crate::drives::Drive { root: PathBuf::from("G:\\"), letter: 'G', label: String::new(), kind, total: 0, free: 0, fs: fs.into(), external }}@@ -547,6 +706,8 @@ mod tests {network: false,cloud: false,rescanning: AtomicBool::new(false),+ ignore: dir.clone(),+ hold: Mutex::new(Hold::default()),});let cancel = Arc::new(AtomicBool::new(false));{diff --git a/crates/rf-win/src/volume.rs b/crates/rf-win/src/volume.rsindex 76d25b47..5ccf3540 100644--- a/crates/rf-win/src/volume.rs+++ b/crates/rf-win/src/volume.rs@@ -184,6 +184,9 @@ pub fn eject(drive_letter: char) -> anyhow::Result<()> {cm.QueryContextMenu(menu, 0, 1, 0x7FFF, CMF_NORMAL).ok()?;let info = CMINVOKECOMMANDINFO {cbSize: std::mem::size_of::<CMINVOKECOMMANDINFO>() as u32,+ // (no window of the shell's own: a refused eject put up Windows' "An error occurred while ejecting" box, with a+ // name of garbage letters on an external disk, behind or beside our own "in use" message: issue 622, 2026-12-05)+ fMask: 0x0000_0400, // CMIC_MASK_FLAG_NO_UIlpVerb: PCSTR(s!("eject").as_ptr()),nShow: SW_SHOWNORMAL.0,..Default::default()