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
External disks are not indexed by themselves, and rustyfiles leaves the folder it was started in (622)
gelenmedya732fe404466b
diff --git a/crates/rf-win/src/indexer.rs b/crates/rf-win/src/indexer.rsindex 60bf1d6d..43c98356 100644--- a/crates/rf-win/src/indexer.rs+++ b/crates/rf-win/src/indexer.rs@@ -380,7 +380,7 @@ pub fn status() -> Vec<(PathBuf, State, usize, usize)> {pub fn local_roots(hard_drives: bool) -> Vec<PathBuf> {crate::drives::list_drives().into_iter()- .filter(|d| d.kind == crate::drives::DriveKind::Fixed && matches!(d.fs.to_ascii_uppercase().as_str(), "NTFS" | "REFS"))+ .filter(indexed_by_itself)// hard drives only when asked for (Settings): walking one is minutes of seeking that can be heard; unknown counts as an SSD.filter(|d| hard_drives || crate::drives::seek_penalty(&d.root) != Some(true)).map(|d| d.root)@@ -424,6 +424,16 @@ fn is_cloud_drive(root: &Path) -> bool {crate::drives::list_drives().iter().any(|d| d.root == root && looks_like_cloud(d))}+/// Whether a drive is indexed without being picked by its letter: an internal fixed disk with NTFS or ReFS.+///+/// NOT AN EXTERNAL DISK (issue 622: "the drive is in use" at every eject). Windows calls a USB hard disk fixed, so it was indexed+/// like an internal one, and the index keeps a handle on the root of every drive it follows (seen on this PC with a handle list:+/// one on each indexed drive's root for as long as rustyfiles runs). A drive with an open handle cannot be ejected. A disk picked+/// by its letter in Settings is still indexed, whatever it is.+fn indexed_by_itself(d: &crate::drives::Drive) -> bool {+ d.kind == crate::drives::DriveKind::Fixed && !d.external && matches!(d.fs.to_ascii_uppercase().as_str(), "NTFS" | "REFS")+}+fn looks_like_cloud(d: &crate::drives::Drive) -> bool {d.kind == crate::drives::DriveKind::Fixed && !d.external && !d.fs.is_empty() && !matches!(d.fs.to_ascii_uppercase().as_str(), "NTFS" | "REFS")}@@ -495,6 +505,18 @@ mod tests {assert!(!looks_like_cloud(&drive(Fixed, "", false)));}+ #[test]+ fn an_external_disk_is_not_indexed_unless_it_is_picked() {+ use crate::drives::DriveKind::*;+ assert!(indexed_by_itself(&drive(Fixed, "NTFS", false)));+ assert!(indexed_by_itself(&drive(Fixed, "ReFS", false)));+ // (issue 622) a USB hard disk: fixed to Windows, and ejected by its user+ assert!(!indexed_by_itself(&drive(Fixed, "NTFS", true)));+ assert!(!indexed_by_itself(&drive(Removable, "NTFS", false)));+ assert!(!indexed_by_itself(&drive(Fixed, "exFAT", false)));+ assert!(!indexed_by_itself(&drive(Network, "NTFS", false)));+ }+/// A start whose saved index can be caught up from the change journal must get through: it caught up, saved the index and went on/// following the drive. (It used to wait for itself for ever.)#[test]diff --git a/crates/rf-win/src/ownfolder.rs b/crates/rf-win/src/ownfolder.rsindex a0d1c55d..ef23d5e8 100644--- a/crates/rf-win/src/ownfolder.rs+++ b/crates/rf-win/src/ownfolder.rs@@ -12,9 +12,15 @@//! window) to 0.7.3 has this.//!//! THE RULE. First thing in `main`, a program whose working directory lies inside its own installation moves to a neutral folder-//! (the user's profile; the temporary folder when there is none). A working directory anywhere else is left alone: a terminal that-//! starts `rustyfiles .` means the folder it stands in, and relative arguments keep their meaning. Nothing in the program reads-//! files relative to the working directory.+//! (the user's profile; the temporary folder when there is none). Nothing in the program reads files relative to the working+//! directory.+//!+//! AND ANY OTHER FOLDER IT WAS STARTED IN, unless an argument needs it (issue 622: a USB disk "in use" at every eject, with no+//! window showing it). A process keeps a handle on its working directory for as long as it lives, and a drive with an open handle+//! cannot be ejected. Whoever starts rustyfiles chooses that directory: a program that opens a folder on the disk, a shortcut's+//! "Start in", AutoPlay. The dock, DirectLook and every program opened from a folder view inherit it. So the process leaves it+//! too, when none of its arguments is a path written relative to it ([`needs_the_folder`]): a terminal's `rustyfiles .` or+//! `rustyfiles sub\file.txt` still means the folder the terminal stands in, and there the directory is kept.use std::path::{Path, PathBuf};@@ -52,15 +58,33 @@ pub fn must_leave(exe: &Path, cwd: &Path) -> bool {install_root(exe).is_some_and(|root| is_inside(cwd, &root))}-/// Called first thing by every program of rustyfiles: leaves the installation folder when the process was started in it. Returns-/// the folder it moved to, `None` when it stays where it is (or cannot move: then nothing has changed).+/// Whether one of the arguments (without the program's own name) only means something from the working directory: a path that is+/// not written in full. Options without a value (`--dock`), full paths (`E:\`, `\\server\share`), shell names (`shell:Downloads`,+/// `::{…}`) and addresses (`ftp://…`) do not. Anything else counts as needing it, an option's value too (`--select=notes.txt`,+/// `/select,notes.txt`): keeping the directory is what every version did, so a doubt changes nothing. Pure.+pub fn needs_the_folder(args: &[String]) -> bool {+ args.iter().any(|a| {+ let a = a.trim().trim_matches('"');+ let whole = Path::new(a).is_absolute() || a.starts_with(r"\\") || a.starts_with("::") || a.contains("://") || a.to_ascii_lowercase().starts_with("shell:");+ let bare_option = a.starts_with("--") && !a.contains('=');+ !(a.is_empty() || whole || bare_option)+ })+}++/// Called first thing by every program of rustyfiles: leaves the installation folder when the process was started in it, and any+/// other folder when no argument needs it. Returns the folder it moved to, `None` when it stays where it is (or cannot move: then+/// nothing has changed).pub fn leave() -> Option<PathBuf> {let exe = std::env::current_exe().ok()?;let cwd = std::env::current_dir().ok()?;- if !must_leave(&exe, &cwd) {+ let args: Vec<String> = std::env::args().skip(1).collect();+ if !must_leave(&exe, &cwd) && needs_the_folder(&args) {return None;}let to = neutral(std::env::var_os("USERPROFILE").map(PathBuf::from).filter(|p| p.is_dir()), std::env::temp_dir());+ if parts(&to) == parts(&cwd) {+ return None;+ }// (a neutral folder that is itself inside the installation would be no way out)if is_inside(&to, &install_root(&exe)?) {return None;@@ -106,6 +130,31 @@ mod tests {assert!(must_leave(copy, Path::new(r"C:\Users\x\AppData\Local\Temp\rustyfiles-update")));}+ #[test]+ fn only_an_argument_written_from_the_folder_keeps_the_process_in_it() {+ let needs = |a: &[&str]| needs_the_folder(&a.iter().map(|s| s.to_string()).collect::<Vec<_>>());+ // what AutoPlay, a folder's "Open" and our own starts give: nothing that needs the folder (issue 622)+ assert!(!needs(&[]));+ assert!(!needs(&[r"N:\"]));+ assert!(!needs(&[r#""N:\Photos\2026""#]));+ assert!(!needs(&[r"\\server\share\x"]));+ assert!(!needs(&["--dock"]));+ assert!(!needs(&["--background"]));+ assert!(!needs(&["shell:Downloads"]));+ assert!(!needs(&["::{645FF040-5081-101B-9F08-00AA002F954E}"]));+ assert!(!needs(&["ftp://example.org/pub"]));+ // a terminal's way of naming things+ assert!(needs(&["."]));+ assert!(needs(&[r"sub\file.txt"]));+ assert!(needs(&["notes.txt"]));+ assert!(needs(&["C:notes.txt"]), "a drive without a root is read from that drive's own directory");+ // an option's value may be such a path: the directory stays, as before+ assert!(needs(&["--select", "notes.txt"]));+ assert!(needs(&["--select=notes.txt"]));+ assert!(needs(&["/select,notes.txt"]));+ assert!(needs(&[r"N:\", "."]));+ }+#[test]fn inside_means_the_folder_or_below_it() {assert!(is_inside(Path::new(r"C:\a\b"), Path::new(r"C:\a")));