mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
refactor: avoid hard coding tmp dir
This commit is contained in:
parent
2ac51faa93
commit
8927b4b162
2 changed files with 5 additions and 4 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
use std::{path::{Path, PathBuf}, sync::Arc};
|
use std::{env, path::{Path, PathBuf}, sync::Arc};
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use config::PREVIEW;
|
use config::PREVIEW;
|
||||||
|
|
@ -57,7 +57,8 @@ impl Image {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn cache(path: &Path) -> PathBuf {
|
pub fn cache(path: &Path) -> PathBuf {
|
||||||
format!("/tmp/yazi/{:x}", Md5::new_with_prefix(path.to_string_lossy().as_bytes()).finalize())
|
env::temp_dir()
|
||||||
.into()
|
.join("yazi")
|
||||||
|
.join(format!("{:x}", Md5::new_with_prefix(path.to_string_lossy().as_bytes()).finalize()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ impl Manager {
|
||||||
let mut manager = toml::from_str::<Outer>(&MERGED_YAZI).unwrap().manager;
|
let mut manager = toml::from_str::<Outer>(&MERGED_YAZI).unwrap().manager;
|
||||||
|
|
||||||
manager.cwd = env::current_dir().unwrap_or("/".into());
|
manager.cwd = env::current_dir().unwrap_or("/".into());
|
||||||
manager.cache = "/tmp/yazi".into();
|
manager.cache = env::temp_dir().join("yazi");
|
||||||
if !manager.cache.is_dir() {
|
if !manager.cache.is_dir() {
|
||||||
fs::create_dir(&manager.cache).unwrap();
|
fs::create_dir(&manager.cache).unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue