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
Folder sizes above a changed folder are measured again, open or not (965); one cell for the app's light/dark
gelenmedya18dd57a892ee
diff --git a/crates/rf-app/src/settings.rs b/crates/rf-app/src/settings.rsindex 46d6f84a..0ef2ec7c 100644--- a/crates/rf-app/src/settings.rs+++ b/crates/rf-app/src/settings.rs@@ -1832,9 +1832,12 @@ pub fn windows_file_explorer_theme() -> bool {/// Effective light/dark appearance without needing an `App`. Kept in an atomic: rows ask for it on every frame,/// and `ThemePref::System` would otherwise read the registry for every row. Icon packs use it to pick a matching variant.+/// The light / dark the app shows now. One cell for [`effective_dark`] and [`set_effective_dark`]: each had a `static` of its own, so a+/// change of Windows' appearance was written where nothing read it and the icon caches stayed on the start's.+static EFFECTIVE_DARK: OnceLock<std::sync::atomic::AtomicBool> = OnceLock::new();+pub fn effective_dark() -> bool {- static DARK: OnceLock<std::sync::atomic::AtomicBool> = OnceLock::new();- DARK.get_or_init(|| std::sync::atomic::AtomicBool::new(compute_effective_dark())).load(Ordering::Relaxed)+ EFFECTIVE_DARK.get_or_init(|| std::sync::atomic::AtomicBool::new(compute_effective_dark())).load(Ordering::Relaxed)}fn compute_effective_dark() -> bool {@@ -1853,8 +1856,7 @@ pub fn system_appearance_changed(dark: bool) {}fn set_effective_dark(dark: bool) {- static DARK: OnceLock<std::sync::atomic::AtomicBool> = OnceLock::new();- DARK.get_or_init(|| std::sync::atomic::AtomicBool::new(false)).store(dark, Ordering::Relaxed);+ EFFECTIVE_DARK.get_or_init(|| std::sync::atomic::AtomicBool::new(dark)).store(dark, Ordering::Relaxed);}/// Read without a `Settings` global, for the shared icon cache.diff --git a/crates/rf-app/src/workspace.rs b/crates/rf-app/src/workspace.rsindex c047f6a6..8bc4e336 100644--- a/crates/rf-app/src/workspace.rs+++ b/crates/rf-app/src/workspace.rs@@ -438,6 +438,11 @@ pub(crate) fn reload_bins(cx: &mut App) {/// notices can't be relied on, and so does the folder tree.pub(crate) fn reread_touched(touched: &rf_core::touched::Touched, cx: &mut App) {let list = cx.try_global::<OpenWorkspaces>().map(|g| g.0.clone()).unwrap_or_default();+ // the sizes remembered for the changed folders and every folder above them, also where no pane shows them now (issue 965: a+ // deletion in a subfolder, then Back, showed the parent's old size)+ for d in touched.all_dirs() {+ rf_win::foldersize::shared_cache().invalidate_up(&d);+ }let dirs = touched.remote_dirs();for (_, ws) in list {let Some(ws) = ws.upgrade() else { continue };diff --git a/crates/rf-core/src/touched.rs b/crates/rf-core/src/touched.rsindex a1041e28..d73f5d89 100644--- a/crates/rf-core/src/touched.rs+++ b/crates/rf-core/src/touched.rs@@ -133,6 +133,17 @@ impl Touched {/// The folders with a changed list that are on a drive whose change notices can't be relied on, in every spelling they may be/// open under.+ /// Every folder whose list or contents changed (the folders listed and the items' own paths), in every spelling they may be open+ /// under. A size measured for any of them or for a folder above them is out of date (issue 965).+ pub fn all_dirs(&self) -> Vec<PathBuf> {+ let mut out = Vec::new();+ for key in self.dirs.keys().chain(self.trees.keys()) {+ out.push(PathBuf::from(key));+ out.extend(self.mapped.on_letters(key).map(PathBuf::from));+ }+ out+ }+pub fn remote_dirs(&self) -> Vec<PathBuf> {let mut out = Vec::new();for (key, _) in self.dirs.iter().filter(|&(_, &remote)| remote) {diff --git a/crates/rf-win/src/foldersize.rs b/crates/rf-win/src/foldersize.rsindex ac2f592f..a8163cab 100644--- a/crates/rf-win/src/foldersize.rs+++ b/crates/rf-win/src/foldersize.rs@@ -531,6 +531,16 @@ impl FolderSizeCache {self.mark_dirty();}+ /// Forgets `dir`, every cached folder below it and each folder above it (only their own entries: a folder beside them keeps its+ /// size). A change deep inside a folder does not move its last-write time, so its size would still answer from the cache.+ pub fn invalidate_up(&self, dir: &Path) {+ let k = key(dir);+ let prefix = format!("{k}\\");+ let above: Vec<String> = dir.ancestors().skip(1).map(key).collect();+ self.map.lock().retain(|p, _| *p != k && !p.starts_with(&prefix) && !above.contains(p));+ self.mark_dirty();+ }+pub fn clear(&self) {self.map.lock().clear();self.mark_dirty();@@ -866,6 +876,24 @@ mod tests {std::fs::remove_dir_all(&r).unwrap();}+ #[test]+ fn a_change_deep_inside_forgets_the_folders_above_but_not_beside() {+ let root = tree("cache-up");+ let cache = FolderSizeCache::default();+ for d in [root.clone(), root.join("a"), root.join("a/b")] {+ cache.get_or_compute(&d, &|| false, &mut |_| {}).unwrap();+ }+ let beside = root.join("beside");+ std::fs::create_dir_all(&beside).unwrap();+ cache.get_or_compute(&beside, &|| false, &mut |_| {}).unwrap();+ // a deletion in a/b: none of the folders above it sees its last-write time move+ cache.invalidate_up(&root.join("a").join("b"));+ assert!(cache.get(&root.join("a").join("b")).is_none(), "the folder itself");+ assert!(cache.get(&root.join("a")).is_none(), "its parent");+ assert!(cache.get(&root).is_none(), "further up");+ assert!(cache.get(&beside).is_some(), "a folder beside them keeps its size");+ }+#[test]fn cache_hits_and_invalidates() {let root = tree("cache");