rename clear option to preload_clear

This commit is contained in:
yggverse 2025-07-07 14:25:39 +03:00
parent a112b49eba
commit 3633aedfd0
4 changed files with 13 additions and 13 deletions

View file

@ -59,9 +59,6 @@ aquatic-crawler --infohash /path/to/info-hash-ipv4.json\
[default: ei] [default: ei]
--clear
Clear previous index collected on crawl session start
--infohash <INFOHASH> --infohash <INFOHASH>
Absolute path(s) or URL(s) to import infohashes from the Aquatic tracker JSON/API 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 <PRELOAD> --preload <PRELOAD>
Directory path to store preloaded data (e.g. `.torrent` files) Directory path to store preloaded data (e.g. `.torrent` files)
--preload-clear
Clear previous data collected on crawl session start
--preload-regex <PRELOAD_REGEX> --preload-regex <PRELOAD_REGEX>
Preload only files match regex pattern (list only without preload by default) Preload only files match regex pattern (list only without preload by default)
* see also `preload_max_filesize`, `preload_max_filecount` options * see also `preload_max_filesize`, `preload_max_filecount` options

View file

@ -11,10 +11,6 @@ pub struct Config {
#[arg(short, long, default_value_t = String::from("ei"))] #[arg(short, long, default_value_t = String::from("ei"))]
pub debug: String, 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 /// Absolute path(s) or URL(s) to import infohashes from the Aquatic tracker JSON/API
/// ///
/// * PR#233 feature /// * PR#233 feature
@ -69,6 +65,10 @@ pub struct Config {
#[arg(long)] #[arg(long)]
pub preload: Option<String>, pub preload: Option<String>,
/// 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) /// Preload only files match regex pattern (list only without preload by default)
/// * see also `preload_max_filesize`, `preload_max_filecount` options /// * see also `preload_max_filesize`, `preload_max_filecount` options
/// ///

View file

@ -38,7 +38,7 @@ async fn main() -> Result<()> {
config.preload_max_filecount, config.preload_max_filecount,
config.preload_max_filesize, config.preload_max_filesize,
config.preload_total_size, config.preload_total_size,
config.clear, config.preload_clear,
)?; )?;
let trackers = Trackers::init(&config.tracker)?; let trackers = Trackers::init(&config.tracker)?;
let torrent = config.export_torrents.map(|p| Torrent::init(&p).unwrap()); let torrent = config.export_torrents.map(|p| Torrent::init(&p).unwrap());

View file

@ -17,14 +17,14 @@ impl Preload {
max_filecount: Option<usize>, max_filecount: Option<usize>,
max_filesize: Option<u64>, max_filesize: Option<u64>,
total_size: Option<u64>, total_size: Option<u64>,
clear: bool, is_clear: bool,
) -> Result<Self> { ) -> Result<Self> {
let path = PathBuf::from_str(directory)?; let path = PathBuf::from_str(directory)?;
if let Ok(t) = fs::metadata(&path) { if let Ok(t) = fs::metadata(&path) {
if t.is_file() { if t.is_file() {
bail!("Storage destination is not directory!"); bail!("Storage destination is not directory!");
} }
if t.is_dir() && clear { if t.is_dir() && is_clear {
for i in fs::read_dir(&path)? { for i in fs::read_dir(&path)? {
let r = i?.path(); let r = i?.path();
if r.is_dir() { if r.is_dir() {
@ -97,7 +97,7 @@ pub fn init(
max_filecount: Option<usize>, max_filecount: Option<usize>,
max_filesize: Option<u64>, max_filesize: Option<u64>,
total_size: Option<u64>, total_size: Option<u64>,
clear: bool, is_clear: bool,
) -> Result<Option<Preload>> { ) -> Result<Option<Preload>> {
Ok(match path { Ok(match path {
Some(ref p) => Some(Preload::init( Some(ref p) => Some(Preload::init(
@ -106,14 +106,14 @@ pub fn init(
max_filecount, max_filecount,
max_filesize, max_filesize,
total_size, total_size,
clear, is_clear,
)?), )?),
None => { None => {
if regex.is_some() if regex.is_some()
|| max_filecount.is_some() || max_filecount.is_some()
|| max_filesize.is_some() || max_filesize.is_some()
|| total_size.is_some() || total_size.is_some()
|| clear || is_clear
{ {
bail!("`--preload` directory is required for this configuration!") bail!("`--preload` directory is required for this configuration!")
} }