mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-21 23:01:05 +00:00
refactor: avoid hard coding tmp dir (#32)
This commit is contained in:
parent
2ac51faa93
commit
f274848dcb
2 changed files with 5 additions and 4 deletions
|
|
@ -1,7 +1,7 @@
|
|||
use std::{path::{Path, PathBuf}, sync::Arc};
|
||||
|
||||
use anyhow::Result;
|
||||
use config::PREVIEW;
|
||||
use config::{MANAGER, PREVIEW};
|
||||
use image::{imageops::FilterType, DynamicImage, ImageFormat};
|
||||
use md5::{Digest, Md5};
|
||||
use shared::tty_ratio;
|
||||
|
|
@ -57,7 +57,8 @@ impl Image {
|
|||
|
||||
#[inline]
|
||||
pub fn cache(path: &Path) -> PathBuf {
|
||||
format!("/tmp/yazi/{:x}", Md5::new_with_prefix(path.to_string_lossy().as_bytes()).finalize())
|
||||
.into()
|
||||
MANAGER
|
||||
.cache
|
||||
.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;
|
||||
|
||||
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() {
|
||||
fs::create_dir(&manager.cache).unwrap();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue