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
Search over every drive: network shares indexed, the drives picked one by one, and a search everywhere from the Omnibar
Dylan-ISEce03bb190537
diff --git a/crates/rf-app/locales/_source.json b/crates/rf-app/locales/_source.jsonindex 653f75d0..ad432d83 100644--- a/crates/rf-app/locales/_source.json+++ b/crates/rf-app/locales/_source.json@@ -14535,5 +14535,35 @@"key": "Pencereler ve düz menüler opak olur, yazılar Windows'un ClearType yumuşatmasıyla çizilir. Yeniden açılan pencerelerde geçerli olur.","tr": "Pencereler ve düz menüler opak olur, yazılar Windows'un ClearType yumuşatmasıyla çizilir. Yeniden açılan pencerelerde geçerli olur.","en": "Windows and solid menus become opaque, and their text is drawn with Windows' ClearType smoothing. Applies to windows opened after the change."+ },+ {+ "id": "e3f873e0",+ "key": "Dizine alınacak sürücüler",+ "tr": "Dizine alınacak sürücüler",+ "en": "Drives to index"+ },+ {+ "id": "e0782fe3",+ "key": "Ağ sürücüleri (SMB paylaşımları) buradan seçilirse dizine alınır: değişiklikler izlenir ve dizin arada bir yeniden taranır. Hiçbir sürücü seçilmemişse yerel diskler otomatik dizine alınır.",+ "tr": "Ağ sürücüleri (SMB paylaşımları) buradan seçilirse dizine alınır: değişiklikler izlenir ve dizin arada bir yeniden taranır. Hiçbir sürücü seçilmemişse yerel diskler otomatik dizine alınır.",+ "en": "Network drives (SMB shares) are indexed when picked here: changes are watched and the index is walked again now and then. With no drive picked, local drives are indexed automatically."+ },+ {+ "id": "c37c3a51",+ "key": "Her yerde ara",+ "tr": "Her yerde ara",+ "en": "Search everywhere"+ },+ {+ "id": "37f09a19",+ "key": "İndirme klasörü",+ "tr": "İndirme klasörü",+ "en": "Download folder"+ },+ {+ "id": "37209f9b",+ "key": "İndirmelerin klasörünü seçin",+ "tr": "İndirmelerin klasörünü seçin",+ "en": "Choose the folder for downloads"}]\ No newline at end of filediff --git a/crates/rf-app/src/i18n_en.rs b/crates/rf-app/src/i18n_en.rsindex 4407081f..64b5af74 100644--- a/crates/rf-app/src/i18n_en.rs+++ b/crates/rf-app/src/i18n_en.rs@@ -550,6 +550,9 @@ pub const EN: &[(&str, &str)] = &[("Sabit diskleri de dizinle", "Index hard drives too"),("Dönen diskler (HDD) varsayılan olarak dizine alınmaz: taranmaları dakikalar sürer ve duyulur. Açılırsa tarama bilgisayar boştayken yapılır.", "Spinning hard drives (HDD) are left out by default: reading one takes minutes and can be heard. When on, the drive is read while the PC is idle."),("dizinlenemedi", "couldn't be indexed"),+ ("Dizine alınacak sürücüler", "Drives to index"),+ ("Ağ sürücüleri (SMB paylaşımları) buradan seçilirse dizine alınır: değişiklikler izlenir ve dizin arada bir yeniden taranır. Hiçbir sürücü seçilmemişse yerel diskler otomatik dizine alınır.", "Network drives (SMB shares) are indexed when picked here: changes are watched and the index is walked again now and then. With no drive picked, local drives are indexed automatically."),+ ("Her yerde ara", "Search everywhere"),("{root} {n} öğe, {mb} MB", "{root} {n} items, {mb} MB"),("aynı hızda", "the same speed"),("Hız testi", "Speed test"),diff --git a/crates/rf-app/src/settings.rs b/crates/rf-app/src/settings.rsindex 317f643d..09691602 100644--- a/crates/rf-app/src/settings.rs+++ b/crates/rf-app/src/settings.rs@@ -951,6 +951,11 @@ pub struct Settings {pub index_excluded: Vec<String>,/// Hard drives (disks with a seek penalty) in the name index too: off by default, walking one is minutes of audible seeking.pub index_hard_drives: bool,+ /// The drive letters the name index covers, when the user chose them one by one ("C", "Z:").+ /// Empty: the automatic set — every local fixed NTFS/ReFS drive (plus hard drives per+ /// [`Self::index_hard_drives`]); network drives are indexed only when picked here (issue 736:+ /// a share is walked, and not everyone wants that traffic).+ pub index_drives: Vec<String>,// ---- Developer toolspub ide_button: IdePref,@@ -1369,6 +1374,7 @@ impl Default for Settings {name_index: true,index_excluded: Vec::new(),index_hard_drives: false,+ index_drives: Vec::new(),ide_button: IdePref::GitRepos,ide_path: String::new(),terminal_path: String::new(),@@ -1811,7 +1817,7 @@ impl Settings {pub(crate) fn apply_side_effects(&self) {rf_win::dock::layout::set_radius(self.dock_corner_radius as f32);rf_win::dock::preview::set_size(self.dock_preview_size.max(1) as f32 / 100.0);- sync_name_index(self.name_index, &self.index_excluded, self.index_hard_drives);+ sync_name_index(self.name_index, &self.index_excluded, self.index_hard_drives, &self.index_drives);crate::i18n::set(self.language);crate::aliases::set(self.folder_aliases.clone());rf_win::openrules::set(self.open_rules.clone());@@ -2318,7 +2324,7 @@ theme = \"dark\"/// Starts or stops the name index when the setting changes. The first start waits a few seconds/// so it never competes with opening the window.-fn sync_name_index(on: bool, excluded: &[String], hard_drives: bool) {+fn sync_name_index(on: bool, excluded: &[String], hard_drives: bool, drives: &[String]) {use std::sync::atomic::{AtomicU8, Ordering};// DirectLook reads these settings too: the index is rustyfiles' (a second indexer would walk// every drive again and write the same index files)@@ -2329,6 +2335,7 @@ fn sync_name_index(on: bool, excluded: &[String], hard_drives: bool) {static STATE: AtomicU8 = AtomicU8::new(0);static EXCLUDED: parking_lot::Mutex<Option<Vec<String>>> = parking_lot::Mutex::new(None);static HARD_DRIVES: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false);+ static DRIVES: parking_lot::Mutex<Option<Vec<String>>> = parking_lot::Mutex::new(None);let list_changed = {let mut e = EXCLUDED.lock();let changed = e.as_deref() != Some(excluded);@@ -2337,7 +2344,14 @@ fn sync_name_index(on: bool, excluded: &[String], hard_drives: bool) {rf_win::nameindex::set_excluded(&excluded.iter().map(std::path::PathBuf::from).collect::<Vec<_>>());}// (hard drives in or out: another set of roots, started anew like a changed list)- HARD_DRIVES.swap(hard_drives, Ordering::Relaxed) != hard_drives || changed+ let mut changed = HARD_DRIVES.swap(hard_drives, Ordering::Relaxed) != hard_drives || changed;+ let mut d = DRIVES.lock();+ if d.as_deref() != Some(drives) {+ *d = Some(drives.to_vec());+ // a letter taken in or out is another set of roots, started anew like a changed list+ changed = true;+ }+ changed};let want = if on { 2 } else { 1 };let was = STATE.swap(want, Ordering::Relaxed);@@ -2350,6 +2364,7 @@ fn sync_name_index(on: bool, excluded: &[String], hard_drives: bool) {return;}let delay = if was == 0 { 5 } else { 0 };+ let drives = drives.to_vec();std::thread::spawn(move || {std::thread::sleep(std::time::Duration::from_secs(delay));// extra instances (tests, the speed test's) leave it to the main one@@ -2366,7 +2381,10 @@ fn sync_name_index(on: bool, excluded: &[String], hard_drives: bool) {// RUSTYFILES_INDEX_ROOTS="E:\;F:\" picks the roots (testing)let roots = match std::env::var("RUSTYFILES_INDEX_ROOTS") {Ok(v) => v.split(';').filter(|s| !s.is_empty()).map(std::path::PathBuf::from).collect(),- Err(_) => rf_win::indexer::local_roots(HARD_DRIVES.load(Ordering::Relaxed)),+ // the drives picked one by one (empty: the automatic set — every local fixed+ // NTFS/ReFS drive, plus hard drives per the setting; network drives only when picked)+ Err(_) if drives.is_empty() => rf_win::indexer::local_roots(HARD_DRIVES.load(Ordering::Relaxed)),+ Err(_) => rf_win::indexer::roots_for_letters(&drives),};rf_win::indexer::start(roots, dir);});diff --git a/crates/rf-app/src/settings_view.rs b/crates/rf-app/src/settings_view.rsindex da72308c..8a63be03 100644--- a/crates/rf-app/src/settings_view.rs+++ b/crates/rf-app/src/settings_view.rs@@ -2892,6 +2892,7 @@ fn files(p: &Palette, s: &Settings, cx: &mut App) -> Vec<AnyElement> {Some(t!("Dönen diskler (HDD) varsayılan olarak dizine alınmaz: taranmaları dakikalar sürer ve duyulur. Açılırsa tarama bilgisayar boştayken yapılır.")),sw("index-hard-drives", p, s.index_hard_drives, |s, v| s.index_hard_drives = v),));+ v.push(index_drives_card(p, s, cx));v.push(index_exclusions(p, s));}v.push(card(@@ -4446,6 +4447,87 @@ fn program_key_name(key: &str) -> &'static str {}}+/// The drives to pick from for the drives-to-index card (issue 736), read off the UI thread like+/// the editors are: a network drive whose server is away answers slowly. With them, the letters+/// the automatic set would index with and without hard drives, so the card can draw every drive+/// with its switch already right. Refreshed while the page is open: a drive plugged in+/// meanwhile shows up.+type DrivePick = (Vec<rf_win::drives::Drive>, Vec<String>, Vec<String>);++fn drive_pick(cx: &mut App) -> DrivePick {+ static PICK: parking_lot::Mutex<Option<(std::time::Instant, DrivePick)>> = parking_lot::Mutex::new(None);+ static LOOKING: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false);+ let fresh = PICK.lock().as_ref().is_some_and(|(at, _)| at.elapsed() < std::time::Duration::from_secs(60));+ if !fresh && !LOOKING.swap(true, std::sync::atomic::Ordering::Relaxed) {+ cx.spawn(async move |cx| {+ let pick = cx+ .background_executor()+ .spawn(async {+ let drives = rf_win::drives::list_drives();+ let letters = |roots: Vec<std::path::PathBuf>| {+ roots.iter().filter_map(|r| r.to_string_lossy().chars().next().map(|c| c.to_ascii_uppercase().to_string())).collect::<Vec<_>>()+ };+ (drives, letters(rf_win::indexer::local_roots(false)), letters(rf_win::indexer::local_roots(true)))+ })+ .await;+ *PICK.lock() = Some((std::time::Instant::now(), pick));+ LOOKING.store(false, std::sync::atomic::Ordering::Relaxed);+ let _ = cx.update(|cx| cx.refresh_windows());+ })+ .detach();+ }+ PICK.lock().as_ref().map(|(_, d)| d.clone()).unwrap_or_else(|| (Vec::new(), Vec::new(), Vec::new()))+}++/// The drives of the name index, one switch each (issue 736). Toggling one freezes the automatic+/// set into the list of drives to index, so a drive that appears later is not indexed unasked —+/// and a network drive (SMB share) only ever is when it was picked here.+fn index_drives_card(p: &Palette, s: &Settings, cx: &mut App) -> AnyElement {+ let (drives, auto_soft, auto_hard) = drive_pick(cx);+ let auto: HashSet<String> = if s.index_hard_drives { auto_hard } else { auto_soft }.into_iter().collect();+ let mut rows = v_flex().py_1();+ for d in drives {+ let letter = d.letter.to_ascii_uppercase().to_string();+ let on = s.index_drives.iter().any(|l| l.eq_ignore_ascii_case(&letter)) || (s.index_drives.is_empty() && auto.contains(&letter));+ let (auto_at_click, letter_at_click) = (auto.iter().cloned().collect::<Vec<String>>(), letter.clone());+ rows = rows.child(+ h_flex()+ .min_h(px(40.))+ .pl(px(56.))+ .pr_4()+ .gap_3()+ .items_center()+ .child(Icon::new(if d.kind == rf_win::drives::DriveKind::Network { L::Network } else { L::HardDrive }).size(px(14.)).text_color(p.text_secondary))+ .child(div().flex_1().min_w_0().text_sm().text_ellipsis().overflow_hidden().whitespace_nowrap().child(d.display_name()))+ .child(switch(+ ElementId::Name(SharedString::from(format!("idx-drive-{letter}"))),+ p,+ on,+ move |_, cx| {+ let (auto_at_click, letter) = (auto_at_click.clone(), letter_at_click.clone());+ settings::update(cx, |s| {+ let mut list: Vec<String> = if s.index_drives.is_empty() { auto_at_click } else { s.index_drives.clone() };+ if list.iter().any(|l| l.eq_ignore_ascii_case(&letter)) {+ list.retain(|l| !l.eq_ignore_ascii_case(&letter));+ } else {+ list.push(letter);+ list.sort_by_key(|l| l.to_ascii_uppercase());+ }+ s.index_drives = list;+ });+ },+ )),+ );+ }+ card(+ p,+ L::Network,+ t!("Dizine alınacak sürücüler"),+ Some(t!("Ağ sürücüleri (SMB paylaşımları) buradan seçilirse dizine alınır: değişiklikler izlenir ve dizin arada bir yeniden taranır. Hiçbir sürücü seçilmemişse yerel diskler otomatik dizine alınır.")),+ rows.into_any_element(),+ )+}+/// "Local drives' file names are kept in an index … · C:\ 2.1 million entries, 84 MB · E:\ indexing…"fn name_index_status() -> String {let mut s = t!("Yerel sürücülerdeki dosya adları bir dizinde tutulur: alt klasörlerde arama milisaniyeler sürer. Dizin arka planda hazırlanır ve güncel tutulur.").to_string();diff --git a/crates/rf-app/src/workspace.rs b/crates/rf-app/src/workspace.rsindex 20f4818e..ce0b1d30 100644--- a/crates/rf-app/src/workspace.rs+++ b/crates/rf-app/src/workspace.rs@@ -135,6 +135,9 @@ pub struct Workspace {editing_address: bool,/// The Omnibar is in search mode (Ctrl+F / its search button) instead of showing the path.search_mode: bool,+ /// The search runs over every indexed drive (issue 736) instead of the tab's folder: the+ /// scope the Omnibar's globe button picks, taken up again from an active search's root.+ search_everywhere: bool,/// (dark, system appearance) last pushed to the window frame (see render).frame_dark: Option<(bool, WindowAppearance)>,/// Background material last applied to the window.@@ -1053,6 +1056,7 @@ impl Workspace {address,editing_address: false,search_mode: false,+ search_everywhere: false,frame_dark: None,applied_backdrop: None,backdrop_pref_seen: None,@@ -2464,9 +2468,14 @@ impl Workspace {/// Searches the active tab's folder and its subfolders for `q`, and remembers the search.fn run_search(&mut self, q: String, window: &mut Window, cx: &mut Context<Self>) {// (a page that is no folder, Home: every indexed drive, the empty root; it searched nothing at all before, issue 377)- let root = match self.active_tab().read(cx).location() {- Location::Search { root, .. } => root.clone(),- l => l.path().map(Path::to_path_buf).unwrap_or_default(),+ // the globe button (or an everywhere-search being edited) widens the scope to every indexed drive, issue 736+ let root = if self.search_everywhere {+ PathBuf::new()+ } else {+ match self.active_tab().read(cx).location() {+ Location::Search { root, .. } => root.clone(),+ l => l.path().map(Path::to_path_buf).unwrap_or_default(),+ }};if q.is_empty() {return;@@ -3646,6 +3655,14 @@ impl Workspace {.children(suggestions).children(chip).child(div().w(px(1.)).h(px(18.)).mx_1().bg(p.divider))+ // (issue 736: while searching, the globe widens the scope to every indexed drive —+ // the scope a search on Home already has; the chip of a live everywhere-search is the same thing)+ .when(searching, |d| {+ d.child(mode_btn("omni-scope", L::Network, self.search_everywhere, "Her yerde ara", cx, |this, _, cx| {+ this.search_everywhere = !this.search_everywhere;+ cx.notify();+ }))+ }).child(mode_btn("omni-cmd", L::SquareChevronRight, self.palette.is_some(), "Komut paleti (Ctrl+Shift+P)", cx, |this, window, cx| {this.toggle_command_palette(window, cx)}))@@ -3689,6 +3706,8 @@ impl Workspace {fn enter_search(&mut self, window: &mut Window, cx: &mut Context<Self>) {self.search_mode = true;self.editing_address = false;+ // an active search keeps its scope: a search that runs everywhere searches everywhere until it says otherwise+ self.search_everywhere = matches!(self.active_tab().read(cx).location(), Location::Search { root, .. } if root.as_os_str().is_empty());self.clear_suggestions();self.search.update(cx, |s, cx| s.focus(window, cx));cx.notify();diff --git a/crates/rf-win/src/indexer.rs b/crates/rf-win/src/indexer.rsindex 954c6f34..cb4df654 100644--- a/crates/rf-win/src/indexer.rs+++ b/crates/rf-win/src/indexer.rs@@ -40,6 +40,11 @@ struct Slot {journaled: bool,/// A disk with a seek penalty (a hard drive): every walk of it waits until the PC is idle.spinning: bool,+ /// A network share (SMB): walked like any root, but its watcher is not to be trusted — a+ /// re-walk keeps it honest (see [`follow`]).+ network: bool,+ /// A re-walk of a network root is running on a thread of its own.+ rescanning: AtomicBool,}/// How long nobody has touched the keyboard or mouse before a walk that can wait starts: a walk reads the whole drive (minutes and@@ -47,6 +52,10 @@ struct Slot {/// with hard drives, gone once rustyfiles was uninstalled).const IDLE_BEFORE_WALK: Duration = Duration::from_secs(60);+/// How often a network root (SMB) is walked again whole: its change reports cannot be counted on+/// (a watcher on a share may report nothing at all), so this is what keeps its index honest.+const RESCAN_NETWORK: Duration = Duration::from_secs(30 * 60);+/// Time since the last keyboard or mouse input in this session.fn idle_for() -> Duration {use windows::Win32::System::SystemInformation::GetTickCount;@@ -105,6 +114,7 @@ pub fn start(roots: Vec<PathBuf>, dir: PathBuf) {for root in roots {let journaled = crate::usn::query(&root).is_some();let spinning = crate::drives::seek_penalty(&root) == Some(true);+ let network = crate::drives::is_network_path(&root);let slot = Arc::new(Slot {file: file_for(&dir, &root),root,@@ -114,6 +124,8 @@ pub fn start(roots: Vec<PathBuf>, dir: PathBuf) {changed_since_save: AtomicBool::new(false),journaled,spinning,+ network,+ rescanning: AtomicBool::new(false),});// 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)@@ -217,7 +229,7 @@ fn run(slot: Arc<Slot>, cancel: Arc<AtomicBool>) {log::info!("indexer: {} caught up from the change journal in {:.2} s, {n} folders listed again", slot.root.display(), t.elapsed().as_secs_f32());slot.changed_since_save.store(true, Ordering::Relaxed);save(&slot);- follow(&slot, &cancel);+ follow(slot, &cancel);return;}Some(Err(e)) => {@@ -244,15 +256,21 @@ fn run(slot: Arc<Slot>, cancel: Arc<AtomicBool>) {slot.changed_since_save.store(true, Ordering::Relaxed);save(&slot);}- follow(&slot, &cancel);+ follow(slot, &cancel);}/// 3. keeps up with changes until cancelled.-fn follow(slot: &Slot, cancel: &AtomicBool) {+fn follow(slot: Arc<Slot>, cancel: &Arc<AtomicBool>) {if slot.journaled {- return follow_journal(slot, cancel);+ return follow_journal(&slot, cancel);}let mut last_save = Instant::now();+ // A share's change reports are not to be trusted (many servers send few or none): once in+ // a while the root is walked again on a thread of its own, so a forgotten rename or a+ // dropped watch does not grow into a stale index. The index on hand keeps answering+ // searches meanwhile, and an empty walk (the share away) changes nothing.+ let rescan_period = slot.network.then_some(RESCAN_NETWORK);+ let mut last_rescan = Instant::now();// The journal position one round ago: by now the watcher has reported every change// before it and the folders were listed again, so the saved index is current up to there// (a start reads from it; reading a little twice costs nothing).@@ -271,10 +289,27 @@ fn follow(slot: &Slot, cancel: &AtomicBool) {}}seen = now;+ if let Some(period) = rescan_period+ && !slot.rescanning.swap(true, Ordering::Relaxed)+ && last_rescan.elapsed() >= period+ {+ last_rescan = Instant::now();+ let (s2, c2) = (slot.clone(), cancel.clone());+ let _ = std::thread::Builder::new().name("rf-indexer".into()).spawn(move || {+ let fresh = Index::build(&s2.root, &c2);+ if !c2.load(Ordering::Relaxed) && !fresh.is_empty() {+ log::info!("indexer: {} re-walked, {} entries", s2.root.display(), fresh.live());+ *s2.index.write() = Some(fresh);+ s2.changed_since_save.store(true, Ordering::Relaxed);+ save(&s2);+ }+ s2.rescanning.store(false, Ordering::Relaxed);+ });+ }// the position alone every minute (a crash or a shutdown then costs little re-reading),// the whole index at most every ten minutes when it changedif !slot.changed_since_save.load(Ordering::Relaxed) && last_save.elapsed() > Duration::from_secs(60) {- save(slot);+ save(slot.as_ref());last_save = Instant::now();} else if last_save.elapsed() > Duration::from_secs(600) {save(&slot);@@ -346,6 +381,36 @@ pub fn local_roots(hard_drives: bool) -> Vec<PathBuf> {.collect()}+/// The mapped network drives worth indexing: reachable SMB shares (a drive whose server did not+/// answer lists with an empty file system and is skipped — indexing it would only fail). There+/// is no change journal over SMB, so these are walked and watched (see [`follow`]).+pub fn network_roots() -> Vec<PathBuf> {+ crate::drives::list_drives()+ .into_iter()+ .filter(|d| d.kind == crate::drives::DriveKind::Network && !d.fs.is_empty())+ .map(|d| d.root)+ .collect()+}++/// The roots of the drive letters the user picked (Settings): every listed letter that is+/// mounted, whatever its kind — a letter asked for by name is indexed even when it is a USB+/// disk or a share. A letter that is not mounted now is left out (and comes back when it is).+pub fn roots_for_letters(letters: &[String]) -> Vec<PathBuf> {+ let want: HashSet<String> = letters+ .iter()+ .filter_map(|s| s.trim().trim_end_matches(':').trim_end_matches('\\').chars().next())+ .map(|c| c.to_ascii_uppercase().to_string())+ .collect();+ if want.is_empty() {+ return Vec::new();+ }+ crate::drives::list_drives()+ .into_iter()+ .filter(|d| want.contains(&d.letter.to_ascii_uppercase().to_string()))+ .map(|d| d.root)+ .collect()+}+pub fn running() -> bool {service().lock().is_some()}@@ -422,6 +487,8 @@ mod tests {changed_since_save: AtomicBool::new(false),journaled: true,spinning: false,+ network: false,+ rescanning: AtomicBool::new(false),});let cancel = Arc::new(AtomicBool::new(false));{