mirror of
https://github.com/Hopiu/lychee.git
synced 2026-05-21 20:11:52 +00:00
Refactor link collection
This commit is contained in:
parent
d6fc698583
commit
b9757c505c
1 changed files with 11 additions and 8 deletions
19
src/main.rs
19
src/main.rs
|
|
@ -89,6 +89,16 @@ fn print_statistics(found: &HashSet<Url>, results: &Vec<CheckStatus>) {
|
|||
println!("🚫Errors: {}", errors);
|
||||
}
|
||||
|
||||
fn collect_links(inputs: Vec<String>) -> Result<HashSet<Url>> {
|
||||
let mut links = HashSet::new();
|
||||
|
||||
for input in inputs {
|
||||
let content = fs::read_to_string(input)?;
|
||||
links.extend(extract_links(&content));
|
||||
}
|
||||
Ok(links)
|
||||
}
|
||||
|
||||
async fn run(opts: LycheeOptions) -> Result<()> {
|
||||
let excludes = RegexSet::new(opts.exclude).unwrap();
|
||||
|
||||
|
|
@ -101,15 +111,8 @@ async fn run(opts: LycheeOptions) -> Result<()> {
|
|||
opts.verbose,
|
||||
)?;
|
||||
|
||||
let mut links = HashSet::new();
|
||||
|
||||
for input in opts.inputs {
|
||||
let md = fs::read_to_string(input)?;
|
||||
links.extend(extract_links(&md));
|
||||
}
|
||||
|
||||
let links = collect_links(opts.inputs)?;
|
||||
let futures: Vec<_> = links.iter().map(|l| checker.check(&l)).collect();
|
||||
|
||||
let results = join_all(futures).await;
|
||||
|
||||
if opts.verbose {
|
||||
|
|
|
|||
Loading…
Reference in a new issue