Skip to content

Commit 5163599

Browse files
authored
fix: only create mapped local working directories for virtual file systems (#3207)
1 parent d905cbf commit 5163599

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

yazi-fs/src/cwd.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,29 @@ impl Cwd {
5353
}
5454

5555
tokio::task::spawn_blocking(move || {
56-
let path = CWD.path();
57-
std::fs::create_dir_all(&path).ok();
56+
let path = CWD.ensure_cache();
5857

5958
_ = set_current_dir(&path);
6059
let cur = current_dir().unwrap_or_default();
6160

6261
unsafe { std::env::set_var("PWD", path) }
6362
SYNCING.store(false, Ordering::Relaxed);
6463

65-
let path = CWD.path();
64+
let path = CWD.ensure_cache();
6665
if cur != path {
67-
std::fs::create_dir_all(&path).ok();
6866
set_current_dir(&path).ok();
6967
unsafe { std::env::set_var("PWD", path) }
7068
}
7169
});
7270
}
71+
72+
fn ensure_cache(&self) -> PathBuf {
73+
let url = self.0.load();
74+
if let Some(p) = provider::cache(url.as_ref()) {
75+
std::fs::create_dir_all(&p).ok();
76+
p
77+
} else {
78+
url.loc.to_path()
79+
}
80+
}
7381
}

0 commit comments

Comments
 (0)