Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(walk): premature walk termination #54

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions src/cmd/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,14 @@ impl Runner {
result
});

trace!("Starting API key collector thread");
let collector_handle = thread::spawn(move || collector.collect());
if let Err(error) = Self::join(&url, collector_handle, walk_handle) {
errors.push(error)
}
});

debug!("Sending stop signal to API key collector");
key_sender
.send(ApiKeyMessage::Stop)
.into_diagnostic()
Expand All @@ -125,18 +127,12 @@ impl Runner {
) -> Result<()> {
let _url = url.as_ref();

debug!("Waiting for collector thread to finish...");
collector_handle
.join()
.expect("ApiKeyCollector thread should have joined successfully");

// match walk_result {
// Ok(_) => {
// info!(target: "keyhunter::main", "Done scraping for {url}");
// }
// Err(e) => {
// error!(target: "keyhunter::main", "[run] Failed to scrape for '{url}': {e}");
// }
// }
debug!("Waiting for walker thread to finish...");
walk_handle
.join()
.expect("WebsiteWalker thread should have joined successfully")
Expand Down
2 changes: 1 addition & 1 deletion src/walk/website/walk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl WebsiteWalker {

fn visit_many(&mut self, urls: Vec<Url>) -> Result<(), Error> {
let pages_to_visit = self.reserve_walk_count(urls.len());
if pages_to_visit == 0 {
if pages_to_visit == 0 && *self.in_progress.get_mut().unwrap() == 0 {
debug!("Finishing walk, No more pages to visit");
self.finish();
return Ok(());
Expand Down
Loading