mirror of
https://github.com/YGGverse/aquatic-crawler.git
synced 2026-03-31 09:05:33 +00:00
use vector as faster and safe here
This commit is contained in:
parent
4f39dc3d0a
commit
5a8adae1d8
2 changed files with 5 additions and 5 deletions
|
|
@ -98,7 +98,7 @@ async fn main() -> Result<()> {
|
|||
// on `preload_regex` case only
|
||||
Ok(AddTorrentResponse::Added(id, mt)) => {
|
||||
let mut only_files_size = 0;
|
||||
let mut only_files_save = HashSet::with_capacity(
|
||||
let mut only_files_keep = Vec::with_capacity(
|
||||
arg.preload_max_filecount.unwrap_or_default(),
|
||||
);
|
||||
let mut only_files = HashSet::with_capacity(
|
||||
|
|
@ -129,7 +129,7 @@ async fn main() -> Result<()> {
|
|||
break;
|
||||
}
|
||||
only_files_size += info.len;
|
||||
only_files_save.insert(storage.absolute(&i, &info.relative_filename));
|
||||
only_files_keep.push(storage.absolute(&i, &info.relative_filename));
|
||||
only_files.insert(id);
|
||||
}
|
||||
}
|
||||
|
|
@ -167,7 +167,7 @@ async fn main() -> Result<()> {
|
|||
)
|
||||
.await?;
|
||||
// cleanup irrelevant files (see rqbit#408)
|
||||
storage.cleanup(&i, Some(only_files_save))?;
|
||||
storage.cleanup(&i, Some(only_files_keep))?;
|
||||
// ignore on the next crawl iterations for this session
|
||||
index.insert(i);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use anyhow::{Result, bail};
|
||||
use std::{collections::HashSet, fs, io::Write, path::PathBuf, str::FromStr};
|
||||
use std::{fs, io::Write, path::PathBuf, str::FromStr};
|
||||
|
||||
pub struct Storage(PathBuf);
|
||||
|
||||
|
|
@ -62,7 +62,7 @@ impl Storage {
|
|||
}
|
||||
|
||||
/// Recursively remove all files under the `infohash` location (see rqbit#408)
|
||||
pub fn cleanup(&self, infohash: &str, keep_filenames: Option<HashSet<PathBuf>>) -> Result<()> {
|
||||
pub fn cleanup(&self, infohash: &str, keep_filenames: Option<Vec<PathBuf>>) -> Result<()> {
|
||||
for e in walkdir::WalkDir::new(self.output_folder(infohash, false)?) {
|
||||
let e = e?;
|
||||
let p = e.into_path();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue