Skip to content

Commit

Permalink
fix: exit loop when paginated DB query returns empty array
Browse files Browse the repository at this point in the history
fixes: #154
  • Loading branch information
realaravinth committed Mar 24, 2024
1 parent 9195550 commit 3a7e71b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/easy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ impl UpdateEasyCaptcha {
}

let mut patterns = data.db.get_all_easy_captchas(limit, offset).await?;
if patterns.is_empty() {
break;
}
for pattern in patterns.drain(0..) {
if !Self::can_run(rx) {
return Ok(());
Expand Down Expand Up @@ -85,6 +88,7 @@ impl UpdateEasyCaptcha {
}
page += 1;
}
Ok(())
}

fn can_run(rx: &mut Receiver<()>) -> bool {
Expand Down

0 comments on commit 3a7e71b

Please sign in to comment.