summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/pipeline/mod.rs31
-rw-r--r--src/watch/detect.rs12
2 files changed, 31 insertions, 12 deletions
diff --git a/src/pipeline/mod.rs b/src/pipeline/mod.rs
index 20648c0..bd37258 100644
--- a/src/pipeline/mod.rs
+++ b/src/pipeline/mod.rs
@@ -14,6 +14,7 @@ use std::path::PathBuf;
use crate::config::Config;
use crate::db::{self, builds, Db, Pkgbase};
use crate::db::model::*;
+use crate::db::SnapshotRow;
use crate::error::{Error, Result};
/// The approved source identity a build must reproduce.
@@ -30,20 +31,27 @@ pub struct SourceIdentity {
pub epoch: String,
pub pkgver: String,
pub pkgrel: String,
- pub identity_hash: String,
}
impl SourceIdentity {
- pub fn from_candidate(c: &CandidateRow) -> Self {
+ /// The identity of a build's source, complete on construction (n-1).
+ ///
+ /// This used to return a value with `aur_commit` and `recipe_hash` left
+ /// empty, which `Ctx::new` filled in afterwards if it happened to find the
+ /// snapshot row — so a `SourceIdentity` was a type whose empty strings could
+ /// mean either "not filled in yet" or "genuinely unknown", and a new call
+ /// site that forgot the second half produced a build that silently recorded
+ /// an empty provenance. The snapshot is an argument now: you cannot build one
+ /// without it.
+ pub fn from_candidate(c: &CandidateRow, snapshot: &SnapshotRow) -> Self {
Self {
- aur_commit: String::new(),
- recipe_hash: String::new(),
+ aur_commit: snapshot.aur_commit.clone(),
+ recipe_hash: snapshot.recipe_hash.clone(),
upstream_pins_json: c.upstream_pins_json.clone(),
source_digests_json: c.source_digests_json.clone(),
epoch: c.epoch.clone(),
pkgver: c.pkgver.clone(),
pkgrel: c.pkgrel.clone(),
- identity_hash: c.identity_hash.clone(),
}
}
pub fn from_release(r: &ReleaseRow) -> Self {
@@ -55,7 +63,6 @@ impl SourceIdentity {
epoch: r.epoch.clone(),
pkgver: r.pkgver.clone(),
pkgrel: r.pkgrel.clone(),
- identity_hash: String::new(),
}
}
pub fn version(&self) -> String {
@@ -125,12 +132,12 @@ impl Ctx {
Some(cid) => {
let c = crate::review::candidates::candidate_by_id(db, cid)?
.ok_or_else(|| Error::not_found("candidate for build"))?;
- let mut si = SourceIdentity::from_candidate(&c);
- if let Some(s) = db::snapshot_by_id(db, c.snapshot_id)? {
- si.aur_commit = s.aur_commit;
- si.recipe_hash = s.recipe_hash;
- }
- si
+ // A candidate without its snapshot is a broken row, not a
+ // candidate with less provenance: say so rather than build
+ // against an empty commit and hash.
+ let snap = db::snapshot_by_id(db, c.snapshot_id)?
+ .ok_or_else(|| Error::not_found("snapshot for candidate"))?;
+ SourceIdentity::from_candidate(&c, &snap)
}
None => {
let rid = build
diff --git a/src/watch/detect.rs b/src/watch/detect.rs
index d2ffd4e..6271dae 100644
--- a/src/watch/detect.rs
+++ b/src/watch/detect.rs
@@ -16,6 +16,18 @@ use crate::time;
use crate::watch::digests::resolve_sources;
use crate::watch::mirror::{read_tree, sync_mirror, Sync};
+/// What one check of one pkgbase resulted in.
+///
+/// Four variants mirror [`Upsert`], and that is deliberate rather than lazy
+/// duplication (n-2). `Upsert` answers a storage question — what did the
+/// candidate write do — and belongs to `review::candidates`; `Outcome` answers
+/// the watcher's question — what should happen next, including the cases that
+/// never reach the candidate table at all (paused, gone, blocked, a
+/// non-publishable notice). Folding them into one enum would put
+/// `Paused`/`Blocked` next to `Collapsed` in the review module, where they mean
+/// nothing, and would make every caller in the scheduler match on storage
+/// vocabulary. `outcome_of` is the total, compiler-checked translation between
+/// the two, and it is the only place that knows both.
#[derive(Debug, Clone)]
pub enum Outcome {
/// Nothing moved at all.