From 6895a3751b4dc7ed4d65d95ba6bb0c5857cde420 Mon Sep 17 00:00:00 2001 From: sxyazi Date: Fri, 26 Sep 2025 17:46:11 +0800 Subject: [PATCH] fix: only create mapped local working directories for virtual file systems --- yazi-fs/src/cwd.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/yazi-fs/src/cwd.rs b/yazi-fs/src/cwd.rs index 0b844959..eccd5101 100644 --- a/yazi-fs/src/cwd.rs +++ b/yazi-fs/src/cwd.rs @@ -53,8 +53,7 @@ impl Cwd { } tokio::task::spawn_blocking(move || { - let path = CWD.path(); - std::fs::create_dir_all(&path).ok(); + let path = CWD.ensure_cache(); _ = set_current_dir(&path); let cur = current_dir().unwrap_or_default(); @@ -62,12 +61,21 @@ impl Cwd { unsafe { std::env::set_var("PWD", path) } SYNCING.store(false, Ordering::Relaxed); - let path = CWD.path(); + let path = CWD.ensure_cache(); if cur != path { - std::fs::create_dir_all(&path).ok(); set_current_dir(&path).ok(); unsafe { std::env::set_var("PWD", path) } } }); } + + fn ensure_cache(&self) -> PathBuf { + let url = self.0.load(); + if let Some(p) = provider::cache(url.as_ref()) { + std::fs::create_dir_all(&p).ok(); + p + } else { + url.loc.to_path() + } + } }