From 3633aedfd01833243ef9e2fd609da5d66976eded Mon Sep 17 00:00:00 2001 From: yggverse Date: Mon, 7 Jul 2025 14:25:39 +0300 Subject: [PATCH] rename `clear` option to `preload_clear` --- README.md | 6 +++--- src/config.rs | 8 ++++---- src/main.rs | 2 +- src/preload.rs | 10 +++++----- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 6f37e76..52dec70 100644 --- a/README.md +++ b/README.md @@ -59,9 +59,6 @@ aquatic-crawler --infohash /path/to/info-hash-ipv4.json\ [default: ei] - --clear - Clear previous index collected on crawl session start - --infohash Absolute path(s) or URL(s) to import infohashes from the Aquatic tracker JSON/API @@ -105,6 +102,9 @@ aquatic-crawler --infohash /path/to/info-hash-ipv4.json\ --preload Directory path to store preloaded data (e.g. `.torrent` files) + --preload-clear + Clear previous data collected on crawl session start + --preload-regex Preload only files match regex pattern (list only without preload by default) * see also `preload_max_filesize`, `preload_max_filecount` options diff --git a/src/config.rs b/src/config.rs index 04b1a05..f571ba0 100644 --- a/src/config.rs +++ b/src/config.rs @@ -11,10 +11,6 @@ pub struct Config { #[arg(short, long, default_value_t = String::from("ei"))] pub debug: String, - /// Clear previous index collected on crawl session start - #[arg(long, default_value_t = false)] - pub clear: bool, - /// Absolute path(s) or URL(s) to import infohashes from the Aquatic tracker JSON/API /// /// * PR#233 feature @@ -69,6 +65,10 @@ pub struct Config { #[arg(long)] pub preload: Option, + /// Clear previous data collected on crawl session start + #[arg(long, default_value_t = false)] + pub preload_clear: bool, + /// Preload only files match regex pattern (list only without preload by default) /// * see also `preload_max_filesize`, `preload_max_filecount` options /// diff --git a/src/main.rs b/src/main.rs index 67b34a8..dd43551 100644 --- a/src/main.rs +++ b/src/main.rs @@ -38,7 +38,7 @@ async fn main() -> Result<()> { config.preload_max_filecount, config.preload_max_filesize, config.preload_total_size, - config.clear, + config.preload_clear, )?; let trackers = Trackers::init(&config.tracker)?; let torrent = config.export_torrents.map(|p| Torrent::init(&p).unwrap()); diff --git a/src/preload.rs b/src/preload.rs index e8ea46f..3d9e213 100644 --- a/src/preload.rs +++ b/src/preload.rs @@ -17,14 +17,14 @@ impl Preload { max_filecount: Option, max_filesize: Option, total_size: Option, - clear: bool, + is_clear: bool, ) -> Result { let path = PathBuf::from_str(directory)?; if let Ok(t) = fs::metadata(&path) { if t.is_file() { bail!("Storage destination is not directory!"); } - if t.is_dir() && clear { + if t.is_dir() && is_clear { for i in fs::read_dir(&path)? { let r = i?.path(); if r.is_dir() { @@ -97,7 +97,7 @@ pub fn init( max_filecount: Option, max_filesize: Option, total_size: Option, - clear: bool, + is_clear: bool, ) -> Result> { Ok(match path { Some(ref p) => Some(Preload::init( @@ -106,14 +106,14 @@ pub fn init( max_filecount, max_filesize, total_size, - clear, + is_clear, )?), None => { if regex.is_some() || max_filecount.is_some() || max_filesize.is_some() || total_size.is_some() - || clear + || is_clear { bail!("`--preload` directory is required for this configuration!") }