mirror of
https://github.com/YGGverse/aquatic-crawler.git
synced 2026-03-31 17:15:35 +00:00
init Preload with validate related argument options
This commit is contained in:
parent
43d94ee9b6
commit
a112b49eba
2 changed files with 45 additions and 15 deletions
|
|
@ -11,7 +11,7 @@ pub struct Preload {
|
|||
}
|
||||
|
||||
impl Preload {
|
||||
pub fn init(
|
||||
fn init(
|
||||
directory: &str,
|
||||
regex: Option<String>,
|
||||
max_filecount: Option<usize>,
|
||||
|
|
@ -89,3 +89,35 @@ impl Preload {
|
|||
self.regex.as_ref().is_some_and(|r| r.is_match(pattern))
|
||||
}
|
||||
}
|
||||
|
||||
/// Init `Preload` with validate related argument options
|
||||
pub fn init(
|
||||
path: Option<String>,
|
||||
regex: Option<String>,
|
||||
max_filecount: Option<usize>,
|
||||
max_filesize: Option<u64>,
|
||||
total_size: Option<u64>,
|
||||
clear: bool,
|
||||
) -> Result<Option<Preload>> {
|
||||
Ok(match path {
|
||||
Some(ref p) => Some(Preload::init(
|
||||
p,
|
||||
regex,
|
||||
max_filecount,
|
||||
max_filesize,
|
||||
total_size,
|
||||
clear,
|
||||
)?),
|
||||
None => {
|
||||
if regex.is_some()
|
||||
|| max_filecount.is_some()
|
||||
|| max_filesize.is_some()
|
||||
|| total_size.is_some()
|
||||
|| clear
|
||||
{
|
||||
bail!("`--preload` directory is required for this configuration!")
|
||||
}
|
||||
None
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue