mirror of
https://github.com/YGGverse/aquatic-crawler.git
synced 2026-04-01 01:25:36 +00:00
update cleanup function api
This commit is contained in:
parent
8e8b60fe31
commit
279c5217da
2 changed files with 6 additions and 5 deletions
|
|
@ -53,16 +53,17 @@ impl Storage {
|
|||
Ok(p.to_string_lossy().to_string())
|
||||
}
|
||||
|
||||
/// Recursively remove all files match `pattern` under `infohash` location
|
||||
pub fn purge_preload_regex(&self, infohash: &str, pattern: &str) -> Result<()> {
|
||||
let r = regex::Regex::new(pattern)?;
|
||||
/// Recursively remove all files under the `infohash` location
|
||||
/// that do not match the `skip_filename_pattern` (see rqbit#408)
|
||||
pub fn cleanup(&self, infohash: &str, skip_filename_pattern: &str) -> Result<()> {
|
||||
let r = regex::Regex::new(skip_filename_pattern)?;
|
||||
for e in walkdir::WalkDir::new(self.output_folder(infohash, false)?)
|
||||
.into_iter()
|
||||
.filter_map(Result::ok)
|
||||
{
|
||||
let p = e.path();
|
||||
if p.is_file() && !r.is_match(p.to_str().unwrap()) {
|
||||
std::fs::remove_file(p)?;
|
||||
fs::remove_file(p)?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue