mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-21 23:01:05 +00:00
fix: use a different cache directory for each user to avoid permission issues (#1541)
This commit is contained in:
parent
4fa37cb3cd
commit
91da9d19cf
11 changed files with 30 additions and 14 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -3477,6 +3477,7 @@ dependencies = [
|
|||
"serde",
|
||||
"shell-words",
|
||||
"tokio",
|
||||
"uzers",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -35,3 +35,4 @@ tokio-stream = "0.1.15"
|
|||
tokio-util = "0.7.11"
|
||||
tracing = { version = "0.1.40", features = [ "max_level_debug", "release_max_level_warn" ] }
|
||||
unicode-width = "0.1.13"
|
||||
uzers = "0.12.1"
|
||||
|
|
|
|||
|
|
@ -31,4 +31,4 @@ tracing = { workspace = true }
|
|||
vergen-gitcl = { version = "1.0.0", features = [ "build" ] }
|
||||
|
||||
[target."cfg(unix)".dependencies]
|
||||
uzers = "0.12.1"
|
||||
uzers = { workspace = true }
|
||||
|
|
|
|||
|
|
@ -18,9 +18,6 @@ use server::*;
|
|||
pub use state::*;
|
||||
use stream::*;
|
||||
|
||||
#[cfg(unix)]
|
||||
pub static USERS_CACHE: yazi_shared::RoCell<uzers::UsersCache> = yazi_shared::RoCell::new();
|
||||
|
||||
pub fn init() {
|
||||
let (tx, rx) = tokio::sync::mpsc::unbounded_channel();
|
||||
|
||||
|
|
@ -38,9 +35,6 @@ pub fn init() {
|
|||
LOCAL.with(<_>::default);
|
||||
REMOTE.with(<_>::default);
|
||||
|
||||
#[cfg(unix)]
|
||||
USERS_CACHE.with(<_>::default);
|
||||
|
||||
// Env
|
||||
if let Some(s) = std::env::var("YAZI_ID").ok().filter(|s| !s.is_empty()) {
|
||||
std::env::set_var("YAZI_PID", s);
|
||||
|
|
|
|||
|
|
@ -52,8 +52,7 @@ impl Stream {
|
|||
use std::env::temp_dir;
|
||||
|
||||
use uzers::Users;
|
||||
|
||||
use crate::USERS_CACHE;
|
||||
use yazi_shared::USERS_CACHE;
|
||||
|
||||
temp_dir().join(format!(".yazi_dds-{}.sock", USERS_CACHE.get_current_uid()))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ unicode-width = { workspace = true }
|
|||
yazi-prebuild = "0.1.2"
|
||||
|
||||
[target."cfg(unix)".dependencies]
|
||||
uzers = "0.12.1"
|
||||
uzers = { workspace = true }
|
||||
|
||||
[target."cfg(windows)".dependencies]
|
||||
clipboard-win = "5.4.0"
|
||||
|
|
|
|||
|
|
@ -6,8 +6,7 @@ impl Utils {
|
|||
#[cfg(unix)]
|
||||
pub(super) fn user(lua: &Lua, ya: &Table) -> mlua::Result<()> {
|
||||
use uzers::{Groups, Users};
|
||||
use yazi_dds::USERS_CACHE;
|
||||
use yazi_shared::hostname;
|
||||
use yazi_shared::{hostname, USERS_CACHE};
|
||||
|
||||
use crate::utils::HOSTNAME_CACHE;
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,9 @@ serde = { workspace = true }
|
|||
shell-words = { workspace = true }
|
||||
tokio = { workspace = true }
|
||||
|
||||
[target."cfg(unix)".dependencies]
|
||||
uzers = { workspace = true }
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
windows-sys = { version = "0.59.0", features = [ "Win32_Storage_FileSystem", "Win32_UI_Shell" ] }
|
||||
|
||||
|
|
|
|||
|
|
@ -39,4 +39,9 @@ pub use time::*;
|
|||
pub use translit::*;
|
||||
pub use xdg::*;
|
||||
|
||||
pub fn init() { event::Event::init(); }
|
||||
pub fn init() {
|
||||
#[cfg(unix)]
|
||||
USERS_CACHE.with(<_>::default);
|
||||
|
||||
event::Event::init();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
#[cfg(unix)]
|
||||
pub static USERS_CACHE: crate::RoCell<uzers::UsersCache> = crate::RoCell::new();
|
||||
|
||||
#[cfg(unix)]
|
||||
pub fn hostname() -> Result<String, std::io::Error> {
|
||||
use std::io::{Error, ErrorKind};
|
||||
|
|
|
|||
|
|
@ -44,5 +44,16 @@ impl Xdg {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn cache_dir() -> PathBuf { env::temp_dir().join("yazi") }
|
||||
pub fn cache_dir() -> PathBuf {
|
||||
#[cfg(unix)]
|
||||
let s = {
|
||||
use uzers::Users;
|
||||
format!("yazi-{}", crate::USERS_CACHE.get_current_uid())
|
||||
};
|
||||
|
||||
#[cfg(windows)]
|
||||
let s = "yazi";
|
||||
|
||||
env::temp_dir().join(s)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue