This commit is contained in:
sxyazi 2026-05-02 21:11:10 +08:00
parent 212670d863
commit 1e75e3a268
No known key found for this signature in database
2 changed files with 6 additions and 8 deletions

View file

@ -55,16 +55,16 @@ impl Stream {
async fn socket_file() -> io::Result<&'static std::path::PathBuf> {
use tokio::{fs::DirBuilder, sync::OnceCell};
use yazi_fs::Xdg;
static ONCE: tokio::sync::OnceCell<std::path::PathBuf> = OnceCell::const_new();
static ONCE: tokio::sync::OnceCell<std::path::PathBuf> = OnceCell::const_new();
ONCE
.get_or_try_init(|| async move {
let p = Xdg::runtime_dir();
#[cfg(unix)]
DirBuilder::new().recursive(true).create(p).await?;
#[cfg(not(unix))]
DirBuilder::new().mode(0o700).recursive(true).create(p).await?;
#[cfg(not(unix))]
DirBuilder::new().recursive(true).create(p).await?;
Ok(p.join(".dds.sock"))
})

View file

@ -25,17 +25,15 @@ impl Xdg {
#[cfg(windows)]
{
dirs::config_dir()
.map(|p| p.join("yazi").join("config"))
.expect("Failed to get config directory")
dirs::config_dir().map(|p| p.join("yazi\\config")).expect("Failed to get config directory")
}
#[cfg(unix)]
{
env::var_os("XDG_CONFIG_HOME")
.map(PathBuf::from)
.filter(|p| p.is_absolute())
.or_else(|| dirs::home_dir().map(|h| h.join(".config")))
.map(|p| p.join("yazi"))
.or_else(|| dirs::home_dir().map(|h| h.join(".config/yazi")))
.expect("Failed to get config directory")
}
}
@ -55,8 +53,8 @@ impl Xdg {
env::var_os("XDG_CACHE_HOME")
.map(PathBuf::from)
.filter(|p| p.is_absolute())
.or_else(|| dirs::home_dir().map(|h| h.join(".cache")))
.map(|p| p.join("yazi"))
.or_else(|| dirs::home_dir().map(|h| h.join(".cache/yazi")))
.expect("Failed to get state directory")
}
}