From c712124f214fc53a57b23c10ed98e8e869cbf7c2 Mon Sep 17 00:00:00 2001 From: aur-build Date: Wed, 18 Nov 2026 18:02:43 +0000 Subject: =?UTF-8?q?watch,=20review,=20config:=20the=20clarity=20minors=20?= =?UTF-8?q?=E2=80=94=20no-ops,=20dead=20params,=20one=20error=20type?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit m-5. `mark_approved_but_unbuilt` was a function that did nothing, called from the failure path with a comment explaining that it did nothing. The mechanism is real — a failed build leaves the accepted pointer alone, and "approved, build failed, index still serving the old version" is what the derived query reads back — but a no-op in the failure path is a trap for whoever traces a build failure at 3am. Deleted; the explanation moved to the call site that needs it. m-6. The step loop extended the lease by a hardcoded 90 seconds while `Config` carried `lease_secs`, so an operator who raised the lease got leases that were silently reset to 90s after the first step. m-8. Dead parameters and `let _ =` debris: `upstream::run` took a `Db` it never used (and a `let _ = local;` after the value's only use), `risk::assess` took a `Pkgbase` it never used, `accepted_pins` took a `Db`, `detect::schedule_next` took a `Pkgbase` it discarded, `diff::version_delta` computed a `vercmp` and threw the answer away, and two HTTP handlers took arguments they ignored. All gone, with the callers following. m-11. `schedule_next` re-queried the subscription for `poll_interval_secs` that its caller had read moments earlier to decide whether the pkgbase was paused — two queries, and two chances to get different answers. The interval is now an argument, and the scheduler's own tick (which already holds the row) was already doing it the right way. m-15. `Config::load`/`save`/`ensure_dirs` returned `anyhow::Result` while the rest of the crate returns `error::Error`, which put two vocabularies on either side of one boundary and turned "there is no config yet, run init" — the one thing a caller can branch on — into an opaque string. They return the crate's error now; `main` keeps `anyhow` at the CLI edge, where it belongs. m-19. `skip_declared` was hardcoded `true` for VCS entries, so the field that means "the recipe gave us no checksum to trust" also meant "this is a git source", and a new `-git` source was rendered to a reviewer as `sha256sums=SKIP` — a warning about a recipe that had done nothing wrong. The field now means one thing everywhere, `SourceDigest::is_vcs()` says which integrity mechanism protects an entry, and the diff panel prints "pinned commit" for those. n-6. `recipe_at` was `pub` for no reason; it is `pub(crate)`. --- src/watch/detect.rs | 27 ++++++++++++++++----------- src/watch/digests.rs | 10 +++++++++- src/watch/upstream.rs | 5 +---- 3 files changed, 26 insertions(+), 16 deletions(-) (limited to 'src/watch') 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 { // 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 { 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) { + 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, ) { 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 diff --git a/src/watch/digests.rs b/src/watch/digests.rs index c67d60e..8136850 100644 --- a/src/watch/digests.rs +++ b/src/watch/digests.rs @@ -48,7 +48,15 @@ pub fn resolve_sources( kind: entry.vcs.clone().unwrap_or_else(|| "vcs".into()), digest, size: 0, - skip_declared: true, + // Computed from the recipe like every other entry (m-19), not + // hardcoded: the field answers "did the recipe give us a + // checksum?", and for a VCS source the answer is usually yes-by- + // absence — which is why renderers must ask `is_vcs` before + // calling it a missing checksum. + skip_declared: match declared_sums(recipe, entry.index) { + Some(d) => d == SKIP || !is_hex_digest(&d), + None => true, + }, }); continue; } diff --git a/src/watch/upstream.rs b/src/watch/upstream.rs index 8d7fa4f..c2772a2 100644 --- a/src/watch/upstream.rs +++ b/src/watch/upstream.rs @@ -214,7 +214,7 @@ pub fn resolve( } let _slot = StageBSlot::acquire(db::setting_i64(db, "stage_b_concurrency", 1) as usize); - let resolved = run(cfg, db, pb, recipe, recipe_hash, &tip_hash, stage_a)?; + let resolved = run(cfg, pb, recipe, recipe_hash, &tip_hash, stage_a)?; db::stage_b_cache_put(db, pb.id, recipe_hash, &tip_hash, &resolved.as_row())?; Ok(Some(resolved)) } @@ -222,7 +222,6 @@ pub fn resolve( /// The actual work: warm the clone cache, then ask `makepkg` what it computes. fn run( cfg: &Config, - db: &Db, pb: &Pkgbase, recipe: &Recipe, recipe_hash: &str, @@ -248,7 +247,6 @@ fn run( if let Ok(local) = git::head(&cache) { if !local.is_empty() && git::has_commit(&cache, &pin.commit) { pin.branch = pin.branch.clone().or_else(|| default_branch(&cache)); - let _ = local; } } } @@ -281,7 +279,6 @@ fn run( if pkgver.is_empty() { return Err(Error::other(format!("makepkg --vercheck produced {text:?}"))); } - let _ = db; Ok(StageB { epoch: recipe.epoch.clone(), pkgver, -- cgit v1.2.3