summaryrefslogtreecommitdiffstats
path: root/src/watch/detect.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/watch/detect.rs')
-rw-r--r--src/watch/detect.rs27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/watch/detect.rs b/src/watch/detect.rs
index 37bdc8a..d2ffd4e 100644
--- a/src/watch/detect.rs
+++ b/src/watch/detect.rs
@@ -53,9 +53,8 @@ pub fn check_pkgbase(cfg: &Config, db: &Db, name: &str) -> Result<CheckReport> {
// broken must not keep opening reviews nobody is going to act on, and it
// must not keep polling AUR either. The pause lives on the subscription, so
// that is what we consult.
- let paused = db::get_subscription(db, name)?
- .map(|s| s.state == SubscriptionState::Paused)
- .unwrap_or(false);
+ let sub = db::get_subscription(db, name)?;
+ let paused = sub.as_ref().map(|s| s.state == SubscriptionState::Paused).unwrap_or(false);
if paused {
return Ok(CheckReport { pkgbase: name.into(), head: String::new(), outcome: Outcome::Paused });
}
@@ -79,18 +78,24 @@ pub fn check_pkgbase(cfg: &Config, db: &Db, name: &str) -> Result<CheckReport> {
Sync::Fetched { head, .. } | Sync::Cloned { head } => head.clone(),
};
let r = analyse(cfg, db, &pb, &head);
- schedule_next(db, name, &pb);
+ schedule_next(db, name, sub.as_ref().and_then(|s| s.poll_interval_secs));
r
}
-fn schedule_next(db: &Db, name: &str, pb: &Pkgbase) {
- let interval = db::subscription_poll_interval(db, name)
- .ok()
- .flatten()
- .unwrap_or(crate::db::setting_i64(db, "poll_interval", 86400));
+/// When to look at this pkgbase again: its own interval if the subscription
+/// carries one, otherwise the global default.
+///
+/// The interval arrives as an argument because the caller read the subscription
+/// row a moment ago to decide whether this pkgbase is paused (m-11); going back
+/// to the database for a number the caller was holding was both a second query
+/// and a second, possibly different, answer.
+fn schedule_next(db: &Db, name: &str, poll_interval: Option<i64>) {
+ let interval = poll_interval.unwrap_or_else(|| crate::db::setting_i64(db, "poll_interval", 86400));
let next = time::secs_ahead(interval);
+ // Best-effort: a missed "next check" stamp means the scheduler looks again
+ // a tick early, not that a change goes unnoticed — the tick re-selects by
+ // `next_check_at` and a NULL is due immediately.
let _ = db::note_check(&db.writer, name, &next, None);
- let _ = pb;
}
/// Everything after the mirror is up to date.
@@ -245,7 +250,7 @@ fn score(
candidate_id: Option<i64>,
) {
let Some(id) = candidate_id else { return };
- if let Ok(a) = crate::review::risk::assess(db, cfg, pb, recipe, digests, accepted) {
+ if let Ok(a) = crate::review::risk::assess(db, cfg, recipe, digests, accepted) {
let _ = crate::review::candidates::set_risk(db, id, &a.level, &a.signals);
}
// Record now what would block the build later, using the same rule the plan