fix: only create mapped local working directories for virtual file systems (#3207)

This commit is contained in:
三咲雅 misaki masa 2025-09-26 17:48:41 +08:00 committed by GitHub
parent d905cbf2d7
commit 51635996e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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()
}
}
}