From 51635996e085ed3b6e6645fc5b6af29179bb3cc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E9=9B=85=20misaki=20masa?= Date: Fri, 26 Sep 2025 17:48:41 +0800 Subject: [PATCH] fix: only create mapped local working directories for virtual file systems (#3207) --- 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() + } + } }