diff --git a/Cargo.lock b/Cargo.lock index 02734893..a61f5cae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2694,6 +2694,7 @@ dependencies = [ "clap_complete_nushell", "serde", "vergen", + "yazi-config", "yazi-shared", ] diff --git a/yazi-boot/Cargo.toml b/yazi-boot/Cargo.toml index 34484e21..71854f4b 100644 --- a/yazi-boot/Cargo.toml +++ b/yazi-boot/Cargo.toml @@ -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 diff --git a/yazi-boot/src/boot.rs b/yazi-boot/src/boot.rs index e62310f1..5de5cea0 100644 --- a/yazi-boot/src/boot.rs +++ b/yazi-boot/src/boot.rs @@ -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 } } diff --git a/yazi-config/src/preview/preview.rs b/yazi-config/src/preview/preview.rs index 1dc2e997..9e3d334c 100644 --- a/yazi-config/src/preview/preview.rs +++ b/yazi-config/src/preview/preview.rs @@ -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,