Skip to content

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.

Eject waits a few seconds for the drive to go before calling it in use (622)

gelenmedya9c5f0792f230
diff --git a/crates/rf-app/src/dock/eject_view.rs b/crates/rf-app/src/dock/eject_view.rs
index a569bd66..40030d96 100644
--- a/crates/rf-app/src/dock/eject_view.rs
+++ b/crates/rf-app/src/dock/eject_view.rs
@@ -207,7 +207,19 @@ impl EjectView {
if failed {
log::warn!("dock: a drive could not be removed safely: {done:?}");
}
- let now = cx.background_executor().spawn(async { read_drives() }).await;
+ // Windows takes the drive away a moment after it says yes: looked at at once, a removal that worked looked failed (issue 622)
+ let now = cx
+ .background_executor()
+ .spawn(async move {
+ let mut now = read_drives();
+ let until = Instant::now() + Duration::from_secs(6);
+ while !failed && now.iter().any(|(l, _)| *l == letter) && Instant::now() < until {
+ std::thread::sleep(Duration::from_millis(250));
+ now = read_drives();
+ }
+ now
+ })
+ .await;
cx.update(|cx| {
// (a drive that is still there after a removal that "worked" is in use after all)
let still = now.iter().any(|(l, _)| *l == letter);
diff --git a/crates/rf-app/src/workspace.rs b/crates/rf-app/src/workspace.rs
index 8bc4e336..e7bd3aa3 100644
--- a/crates/rf-app/src/workspace.rs
+++ b/crates/rf-app/src/workspace.rs
@@ -4604,7 +4604,15 @@ impl Workspace {
.background_executor()
.spawn(async move {
let r = rf_win::sta::call(std::time::Duration::from_secs(30), move || rf_win::volume::eject(letter).map_err(|e| e.to_string()));
- let still = std::path::Path::new(&format!("{letter}:\\")).exists();
+ // Windows takes the drive away a moment after it says yes: looked at at once, an eject that worked was reported as
+ // "in use" (issue 622's log: "could not be removed safely: Some(Ok(())) (still there: true)")
+ let root = format!("{letter}:\\");
+ let mut still = std::path::Path::new(&root).exists();
+ let until = std::time::Instant::now() + std::time::Duration::from_secs(6);
+ while still && matches!(r, Some(Ok(()))) && std::time::Instant::now() < until {
+ std::thread::sleep(std::time::Duration::from_millis(250));
+ still = std::path::Path::new(&root).exists();
+ }
(r, still)
})
.await;