This commit is contained in:
sxyazi 2024-02-26 08:00:45 +08:00
parent bfcf77c9a2
commit 40c6da1ba8
No known key found for this signature in database
4 changed files with 16 additions and 14 deletions

1
Cargo.lock generated
View file

@ -2694,6 +2694,7 @@ dependencies = [
"clap_complete_nushell",
"serde",
"vergen",
"yazi-config",
"yazi-shared",
]

View file

@ -9,6 +9,7 @@ homepage = "https://yazi-rs.github.io"
repository = "https://github.com/sxyazi/yazi"
[dependencies]
yazi-config = { path = "../yazi-config", version = "0.2.3" }
yazi-shared = { path = "../yazi-shared", version = "0.2.3" }
# External dependencies

View file

@ -2,6 +2,7 @@ use std::{ffi::OsString, fs, path::{Path, PathBuf}, process};
use clap::Parser;
use serde::Serialize;
use yazi_config::PREVIEW;
use yazi_shared::{fs::{current_cwd, expand_path}, Xdg};
use super::Args;
@ -67,6 +68,19 @@ impl Default for Args {
process::exit(0);
}
if args.clear_cache {
if PREVIEW.cache_dir == Xdg::cache_dir() {
println!("Clearing cache directory: \n{:?}", PREVIEW.cache_dir);
fs::remove_dir_all(&PREVIEW.cache_dir).unwrap();
} else {
println!(
"You've changed the default cache directory, for your data's safety, please clear it manually: \n{:?}",
PREVIEW.cache_dir
);
}
process::exit(0);
}
args
}
}

View file

@ -56,20 +56,6 @@ impl Default for Preview {
fs::create_dir(&cache_dir).unwrap();
}
// TODO: xx
// if ARGS.clear_cache {
// if cache_dir == Xdg::cache_dir() {
// println!("Clearing cache directory: \n{:?}", cache_dir);
// fs::remove_dir_all(&cache_dir).unwrap();
// } else {
// println!(
// "You've changed the default cache directory, for your data's safety, please
// clear it manually: \n{:?}", cache_dir
// );
// }
// process::exit(0);
// }
Preview {
tab_size: preview.tab_size,
max_width: preview.max_width,