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
Cloud sync folders in the name index: the walk enters their reparse directories, and they are picked in Settings like drives
Dylan-ISE0b16d915141d
diff --git a/crates/rf-app/locales/_source.json b/crates/rf-app/locales/_source.jsonindex ae8a4ab2..a6b8dfdc 100644--- a/crates/rf-app/locales/_source.json+++ b/crates/rf-app/locales/_source.json@@ -15189,5 +15189,17 @@"key": "Sağ adadaki tepsi simgeleri birbirine daha yakın durur; aynı yere daha çok simge sığar. Yalnızca adada gösterilen program simgelerine uygulanır: ^ panelindekilere ve Windows'un kendi göstergelerine (ağ, ses, güvenlik) uygulanmaz.","tr": "Sağ adadaki tepsi simgeleri birbirine daha yakın durur; aynı yere daha çok simge sığar. Yalnızca adada gösterilen program simgelerine uygulanır: ^ panelindekilere ve Windows'un kendi göstergelerine (ağ, ses, güvenlik) uygulanmaz.","en": "The tray icons of the right island stand closer together; more icons fit in the same room. Applies only to the program icons shown on the island, not to those in the ^ panel or Windows' own indicators (network, sound, security)."+ },+ {+ "id": "8b74d71b",+ "key": "Bulut klasörleri",+ "tr": "Bulut klasörleri",+ "en": "Cloud folders"+ },+ {+ "id": "2716175c",+ "key": "OneDrive ve benzeri bulut klasörleri buradan seçilir: seçilen klasörün kendi dizini tutulur, seçilmeyen disk taranırken atlanır.",+ "tr": "OneDrive ve benzeri bulut klasörleri buradan seçilir: seçilen klasörün kendi dizini tutulur, seçilmeyen disk taranırken atlanır.",+ "en": "Cloud folders such as OneDrive are picked here: a picked folder gets an index of its own, and an unpicked one is left out of its drive's walk."}]\ No newline at end of filediff --git a/crates/rf-app/src/i18n_en.rs b/crates/rf-app/src/i18n_en.rsindex 73cf6a35..ce06f57e 100644--- a/crates/rf-app/src/i18n_en.rs+++ b/crates/rf-app/src/i18n_en.rs@@ -579,6 +579,8 @@ pub const EN: &[(&str, &str)] = &[("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."),+ ("Bulut klasörleri", "Cloud folders"),+ ("OneDrive ve benzeri bulut klasörleri buradan seçilir: seçilen klasörün kendi dizini tutulur, seçilmeyen disk taranırken atlanır.", "Cloud folders such as OneDrive are picked here: a picked folder gets an index of its own, and an unpicked one is left out of its drive's walk."),("Her yerde ara", "Search everywhere"),("{root} {n} öğe, {mb} MB", "{root} {n} items, {mb} MB"),("aynı hızda", "the same speed"),diff --git a/crates/rf-app/src/settings.rs b/crates/rf-app/src/settings.rsindex 63b36756..0c7f2e17 100644--- a/crates/rf-app/src/settings.rs+++ b/crates/rf-app/src/settings.rs@@ -1115,6 +1115,10 @@ pub struct Settings {/// [`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>,+ /// The cloud sync folders (OneDrive, Proton Drive, …) the name index covers, as paths.+ /// Empty: none — a cloud folder is walked only when picked here (issue 885), and an+ /// unpicked one is left out of its drive's walk like a folder the user excluded.+ pub index_clouds: Vec<String>,// ---- Developer toolspub ide_button: IdePref,@@ -1560,6 +1564,7 @@ impl Default for Settings {index_excluded: Vec::new(),index_hard_drives: false,index_drives: Vec::new(),+ index_clouds: Vec::new(),ide_button: IdePref::GitRepos,ide_path: String::new(),terminal_path: String::new(),@@ -2038,7 +2043,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, &self.index_drives);+ sync_name_index(self.name_index, &self.index_excluded, self.index_hard_drives, &self.index_drives, &self.index_clouds);crate::i18n::set(self.language);crate::aliases::set(self.folder_aliases.clone());rf_win::openrules::set(self.open_rules.clone());@@ -2609,7 +2614,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, drives: &[String]) {+fn sync_name_index(on: bool, excluded: &[String], hard_drives: bool, drives: &[String], clouds: &[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)@@ -2621,15 +2626,34 @@ fn sync_name_index(on: bool, excluded: &[String], hard_drives: bool, drives: &[Sstatic 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);+ static CLOUDS: 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);- if changed {+ let excluded_changed = e.as_deref() != Some(excluded);+ let mut c = CLOUDS.lock();+ let clouds_changed = c.as_deref() != Some(clouds);+ if clouds_changed {+ *c = Some(clouds.to_vec());+ }+ // the cloud folders not picked for the index are left out of their drive's walk like+ // folders the user excluded (the walk does enter cloud folders, issue 885); the skip+ // list is rebuilt only when one of its two sources changed+ if excluded_changed || clouds_changed {+ let picked: Vec<String> = clouds.iter().map(|s| s.trim_end_matches('\\').to_lowercase()).collect();+ let mut skip: Vec<std::path::PathBuf> = excluded.iter().map(std::path::PathBuf::from).collect();+ for r in rf_win::syncroots::list() {+ let p = r.path.to_string_lossy().trim_end_matches('\\').to_lowercase();+ if !picked.iter().any(|k| *k == p) {+ skip.push(r.path.clone());+ }+ }+ rf_win::nameindex::set_excluded(&skip);+ }+ if excluded_changed {*e = Some(excluded.to_vec());- 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)- let mut changed = HARD_DRIVES.swap(hard_drives, Ordering::Relaxed) != hard_drives || changed;+ let mut changed = HARD_DRIVES.swap(hard_drives, Ordering::Relaxed) != hard_drives || excluded_changed || clouds_changed;let mut d = DRIVES.lock();if d.as_deref() != Some(drives) {*d = Some(drives.to_vec());@@ -2650,6 +2674,7 @@ fn sync_name_index(on: bool, excluded: &[String], hard_drives: bool, drives: &[S}let delay = if was == 0 { 5 } else { 0 };let drives = drives.to_vec();+ let clouds = clouds.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@@ -2667,9 +2692,13 @@ fn sync_name_index(on: bool, excluded: &[String], hard_drives: bool, drives: &[Slet roots = match std::env::var("RUSTYFILES_INDEX_ROOTS") {Ok(v) => v.split(';').filter(|s| !s.is_empty()).map(std::path::PathBuf::from).collect(),// 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),+ // NTFS/ReFS drive, plus hard drives per the setting; network drives only when+ // picked) and the cloud folders picked on top (issue 885)+ Err(_) => {+ let mut roots = if drives.is_empty() { rf_win::indexer::local_roots(HARD_DRIVES.load(Ordering::Relaxed)) } else { rf_win::indexer::roots_for_letters(&drives) };+ roots.extend(clouds.iter().map(std::path::PathBuf::from));+ roots+ }};rf_win::indexer::start(roots, dir);});diff --git a/crates/rf-app/src/settings_view.rs b/crates/rf-app/src/settings_view.rsindex 30232904..f8fd808d 100644--- a/crates/rf-app/src/settings_view.rs+++ b/crates/rf-app/src/settings_view.rs@@ -4815,7 +4815,7 @@ fn program_key_name(key: &str) -> &'static str {/// 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>);+type DrivePick = (Vec<rf_win::drives::Drive>, Vec<String>, Vec<String>, Vec<rf_win::syncroots::SyncRoot>);fn drive_pick(cx: &mut App) -> DrivePick {static PICK: parking_lot::Mutex<Option<(std::time::Instant, DrivePick)>> = parking_lot::Mutex::new(None);@@ -4830,7 +4830,7 @@ fn drive_pick(cx: &mut App) -> DrivePick {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)))+ (drives, letters(rf_win::indexer::local_roots(false)), letters(rf_win::indexer::local_roots(true)), rf_win::syncroots::list())}).await;*PICK.lock() = Some((std::time::Instant::now(), pick));@@ -4839,14 +4839,14 @@ fn drive_pick(cx: &mut App) -> DrivePick {}).detach();}- PICK.lock().as_ref().map(|(_, d)| d.clone()).unwrap_or_else(|| (Vec::new(), Vec::new(), Vec::new()))+ PICK.lock().as_ref().map(|(_, d)| d.clone()).unwrap_or_else(|| (Vec::new(), 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 (drives, auto_soft, auto_hard, clouds) = 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 {@@ -4882,11 +4882,62 @@ fn index_drives_card(p: &Palette, s: &Settings, cx: &mut App) -> AnyElement {)),);}+ // the cloud sync folders (OneDrive, Proton Drive, …): their directories are reparse points+ // the walk now enters, so a folder not picked here is left out of its drive's walk like an+ // excluded folder — the switch holds either way (issue 885)+ if !clouds.is_empty() {+ rows = rows+ .child(div().h(px(1.)).bg(p.divider))+ .child(+ h_flex()+ .min_h(px(36.))+ .pl(px(56.))+ .pr_4()+ .gap_2()+ .items_center()+ .child(Icon::new(L::Cloud).size(px(14.)).text_color(p.text_secondary))+ .child(+ v_flex()+ .child(div().text_sm().child(t!("Bulut klasörleri")))+ .child(div().text_xs().text_color(p.text_secondary).child(t!("OneDrive ve benzeri bulut klasörleri buradan seçilir: seçilen klasörün kendi dizini tutulur, seçilmeyen disk taranırken atlanır."))),+ ),+ );+ for r in clouds {+ let path = r.path.to_string_lossy().trim_end_matches('\\').to_string();+ let on = s.index_clouds.iter().any(|c| c.eq_ignore_ascii_case(&path));+ let picked = path.clone();+ rows = rows.child(+ h_flex()+ .min_h(px(40.))+ .pl(px(56.))+ .pr_4()+ .gap_3()+ .items_center()+ .child(Icon::new(L::Cloud).size(px(14.)).text_color(p.text_secondary))+ .child(div().flex_1().min_w_0().text_sm().text_ellipsis().overflow_hidden().whitespace_nowrap().child(if r.name.is_empty() { path.clone() } else { r.name }))+ .child(switch(+ ElementId::Name(SharedString::from(format!("idx-cloud-{path}"))),+ p,+ on,+ move |_, cx| {+ let picked = picked.clone();+ settings::update(cx, |s| {+ if s.index_clouds.iter().any(|c| c.eq_ignore_ascii_case(&picked)) {+ s.index_clouds.retain(|c| !c.eq_ignore_ascii_case(&picked));+ } else {+ s.index_clouds.push(picked);+ }+ });+ },+ )),+ );+ }+ }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.")),+ 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. Bulut klasörleri (OneDrive ve benzeri) de buradan seçilir. Hiçbir sürücü seçilmemişse yerel diskler otomatik dizine alınır.")),rows.into_any_element(),)}diff --git a/crates/rf-win/src/nameindex.rs b/crates/rf-win/src/nameindex.rsindex ce722998..d95751a1 100644--- a/crates/rf-win/src/nameindex.rs+++ b/crates/rf-win/src/nameindex.rs@@ -249,7 +249,9 @@ struct Chunk {frns: Vec<(u32, u64)>,}-fn flags_of(a: u32) -> u8 {+const CLOUD: u8 = 8;++fn flags_of(a: u32, tag: u32) -> u8 {let mut f = 0;if a & attrs::DIRECTORY != 0 {f |= DIR;@@ -259,6 +261,14 @@ fn flags_of(a: u32) -> u8 {}if a & attrs::REPARSE_POINT != 0 {f |= REPARSE;+ // A cloud sync folder (OneDrive, Proton Drive, pCloud, …: the Windows Cloud Files API+ // reparse tags 0x9000xxxx) is a reparse point whose files are all there — its name+ // records are local metadata, and walking it is how its files get into the index at+ // all (issue 885). It is told from a junction or a symlink by the tag, which the walk+ // reads (dwReserved0 of WIN32_FIND_DATAW, ReparseTag of FILE_ID_BOTH_DIR_INFO).+ if tag & 0xF000_0000 == 0x9000_0000 {+ f |= CLOUD;+ }}f}@@ -293,21 +303,21 @@ struct Listing {/// available (some network or FAT volumes), `FindFirstFileEx` without ids.fn list(dir: &Path) -> Listing {let mut out = Listing { names: Vec::new(), lens: Vec::new(), flags: Vec::new(), ids: Vec::new() };- let mut push = |name: &[u16], attrs: u32, id: u64| {+ let mut push = |name: &[u16], attrs: u32, tag: u32, id: u64| {if name == [b'.' as u16] || name == [b'.' as u16, b'.' as u16] {return;}let s = String::from_utf16_lossy(name);out.names.extend_from_slice(s.as_bytes());out.lens.push(s.len().min(u16::MAX as usize) as u16);- out.flags.push(flags_of(attrs));+ out.flags.push(flags_of(attrs, tag));out.ids.push(id);};if PLAIN_LISTING.load(Ordering::Relaxed) || list_with_ids(dir, &mut push).is_none() {let _ = for_each_raw(dir, |d| {let n = &d.cFileName;let end = n.iter().position(|&c| c == 0).unwrap_or(n.len());- push(&n[..end], d.dwFileAttributes, 0);+ push(&n[..end], d.dwFileAttributes, d.dwReserved0, 0);});}out@@ -438,10 +448,15 @@ pub fn catch_up_locked(lock: &parking_lot::RwLock<Option<Index>>, cancel: &Atomi}/// `None` when the folder can't be read this way (the caller falls back).-fn list_with_ids(dir: &Path, push: &mut impl FnMut(&[u16], u32, u64)) -> Option<()> {+/// The same listing with file ids (what the change journal knows a folder by) and, with them,+/// each entry's reparse tag. Read with `FileIdExtdDirectoryInfo`: the both-dir class the walk+/// used before carries no tag (issue 885: without one, a cloud folder and a junction are+/// indistinguishable and the walk could enter neither), and where this class is not supported+/// (some network or FAT volumes) `list` falls back to `FindFirstFileEx`, which has the tag.+fn list_with_ids(dir: &Path, push: &mut impl FnMut(&[u16], u32, u32, u64)) -> Option<()> {use windows::Win32::Foundation::{CloseHandle, GENERIC_READ};use windows::Win32::Storage::FileSystem::{- CreateFileW, FILE_FLAG_BACKUP_SEMANTICS, FILE_ID_BOTH_DIR_INFO, FILE_SHARE_DELETE, FILE_SHARE_READ, FILE_SHARE_WRITE, FileIdBothDirectoryInfo, FileIdBothDirectoryRestartInfo,+ CreateFileW, FILE_FLAG_BACKUP_SEMANTICS, FILE_ID_EXTD_DIR_INFO, FILE_SHARE_DELETE, FILE_SHARE_READ, FILE_SHARE_WRITE, FileIdExtdDirectoryInfo, FileIdExtdDirectoryRestartInfo,GetFileInformationByHandleEx, OPEN_EXISTING,};let w = crate::wide::long_path(dir);@@ -452,7 +467,7 @@ fn list_with_ids(dir: &Path, push: &mut impl FnMut(&[u16], u32, u64)) -> Option<let mut first = true;let ok;loop {- let class = if first { FileIdBothDirectoryRestartInfo } else { FileIdBothDirectoryInfo };+ let class = if first { FileIdExtdDirectoryRestartInfo } else { FileIdExtdDirectoryInfo };if unsafe { GetFileInformationByHandleEx(h, class, buf.as_mut_ptr() as *mut _, bytes as u32) }.is_err() {// ERROR_NO_MORE_FILES ends a listing; anything on the first call means "not here"ok = !first;@@ -462,9 +477,12 @@ fn list_with_ids(dir: &Path, push: &mut impl FnMut(&[u16], u32, u64)) -> Option<let base = buf.as_ptr() as *const u8;let mut off = 0usize;loop {- let info = unsafe { &*(base.add(off) as *const FILE_ID_BOTH_DIR_INFO) };+ let info = unsafe { &*(base.add(off) as *const FILE_ID_EXTD_DIR_INFO) };let name = unsafe { std::slice::from_raw_parts(info.FileName.as_ptr(), info.FileNameLength as usize / 2) };- push(name, info.FileAttributes, info.FileId as u64);+ // on NTFS the file id is the file record number in the first 8 bytes, what the+ // change journal names; the last 8 are the sequence, which the journal leaves out+ let id = u64::from_le_bytes(info.FileId.Identifier[0..8].try_into().unwrap());+ push(name, info.FileAttributes, info.ReparsePointTag, id);if info.NextEntryOffset == 0 {break;}@@ -717,7 +735,7 @@ impl Index {continue;}let Some(e) = t.entries.get(l.record as usize).filter(|e| e.used()) else { continue };- let mut f = flags_of(e.attrs) & !DIR;+ let mut f = flags_of(e.attrs, 0) & !DIR;if e.dir() {f |= DIR;}@@ -1463,6 +1481,41 @@ mod tests {std::fs::remove_dir_all(&root).unwrap();}+ #[test]+ fn a_cloud_reparse_folder_is_marked_and_a_junction_is_not() {+ let dir = attrs::DIRECTORY | attrs::REPARSE_POINT;+ // OneDrive's own tag, measured with fsutil (issue 885), and the family's first tag+ assert_eq!(flags_of(dir, 0x9000_601a) & CLOUD, CLOUD);+ assert_eq!(flags_of(dir, 0x9000_0001) & CLOUD, CLOUD);+ // a junction and a symlink are reparse points of another family: listed, never entered+ assert_eq!(flags_of(dir, 0xA000_0003) & CLOUD, 0);+ assert_eq!(flags_of(dir, 0xA000_000C) & CLOUD, 0);+ // a file with a cloud tag is marked as a cloud reparse point, but is no folder to walk into+ let f = flags_of(attrs::REPARSE_POINT, 0x9000_601a);+ assert_eq!(f & CLOUD, CLOUD);+ assert_eq!(f & DIR, 0);+ }++ /// A junction is listed but its contents are not; that is what keeps the walk out of loops+ /// and of double-indexed folders — and why the cloud folders needed their own tag.+ #[test]+ fn a_junction_is_listed_but_its_contents_are_not() {+ let root = tree("junction");+ let target = std::env::temp_dir().join(format!("rf-nameindex-junction-target-{}", std::process::id()));+ let _ = std::fs::remove_dir_all(&target);+ std::fs::create_dir_all(target.join("ic")).unwrap();+ std::fs::write(target.join("ic").join("derin.txt"), b"x").unwrap();+ let link = root.join("Baglanti");+ let out = std::process::Command::new("cmd").args(["/C", "mklink", "/J"]).arg(&link).arg(&target).output().unwrap();+ assert!(out.status.success(), "mklink /J failed: {}", String::from_utf8_lossy(&out.stderr));+ let ix = Index::build(&root, &AtomicBool::new(false));+ // the junction itself is found by name, what is behind it is not+ assert_eq!(ix.search("Baglanti", None, false, 10).unwrap().len(), 1);+ assert!(ix.search("derin", None, false, 10).unwrap().is_empty());+ std::fs::remove_dir_all(&root).unwrap();+ let _ = std::fs::remove_dir_all(&target);+ }+/// A change inside a folder the index leaves out does not bring its contents in.#[test]fn left_out_folders_stay_out_after_changes() {