fix: move the DDS socket file out of the cache directory to avoid being affected by yazi --clear-cache

This commit is contained in:
sxyazi 2024-04-27 16:47:50 +08:00
parent 681612f976
commit d01e18067c
No known key found for this signature in database
2 changed files with 5 additions and 9 deletions

View File

@ -49,15 +49,10 @@ impl Default for Preview {
let preview = toml::from_str::<Outer>(&MERGED_YAZI).unwrap().preview;
check_validation(preview.validate());
let mut cache_dir = Xdg::cache_dir();
let cache_dir =
preview.cache_dir.filter(|p| !p.is_empty()).map_or_else(Xdg::cache_dir, expand_path);
std::fs::create_dir_all(&cache_dir).expect("Failed to create cache directory");
// If the `cache_dir` is set in the configuration file, use it instead
if let Some(p) = preview.cache_dir.filter(|s| !s.is_empty()).map(expand_path) {
cache_dir = p;
std::fs::create_dir_all(&cache_dir).expect("Failed to create cache directory");
}
Preview {
tab_size: preview.tab_size,
max_width: preview.max_width,

View File

@ -49,11 +49,12 @@ impl Stream {
#[cfg(unix)]
fn socket_file() -> std::path::PathBuf {
use std::env::temp_dir;
use uzers::Users;
use yazi_shared::Xdg;
use crate::USERS_CACHE;
Xdg::cache_dir().join(format!(".dds-{}.sock", USERS_CACHE.get_current_uid()))
temp_dir().join(format!(".yazi_dds-{}.sock", USERS_CACHE.get_current_uid()))
}
}