diff options
Diffstat (limited to 'src/pipeline')
| -rw-r--r-- | src/pipeline/mod.rs | 6 | ||||
| -rw-r--r-- | src/pipeline/steps.rs | 27 |
2 files changed, 17 insertions, 16 deletions
diff --git a/src/pipeline/mod.rs b/src/pipeline/mod.rs index e7ee34e..42f435f 100644 --- a/src/pipeline/mod.rs +++ b/src/pipeline/mod.rs @@ -10,7 +10,7 @@ use crate::config::Config; use crate::db::{self, builds, Db, Pkgbase}; use crate::db::model::*; use crate::db::SnapshotRow; -use crate::error::{Error, Result}; +use crate::error::{Error, Missing, Result}; use crate::sandbox::{Sandbox, SandboxBackend}; #[derive(Debug, Clone)] @@ -104,7 +104,7 @@ pub struct Ctx { impl Ctx { pub fn new(cfg: &Config, db: &Db, build_id: &str) -> Result<Self> { let build = builds::get(db, build_id)? - .ok_or_else(|| Error::not_found(format!("build {build_id}")))?; + .ok_or_else(|| Error::not_found(Missing::Build(build_id.to_string())))?; let pb = db::get_pkgbase_by_id(db, build.pkgbase_id)? .ok_or_else(|| Error::not_found("pkgbase for build"))?; let src = match build.candidate_id { @@ -262,7 +262,7 @@ pub fn enqueue_for_candidate(cfg: &Config, db: &Db, c: &CandidateRow) -> Result< pub fn enqueue_manual_rebuild(cfg: &Config, db: &Db, pkgbase: &str) -> Result<String> { let pb = db::get_pkgbase(db, pkgbase)? - .ok_or_else(|| Error::not_found(format!("pkgbase {pkgbase}")))?; + .ok_or_else(|| Error::not_found(Missing::Pkgbase(pkgbase.to_string())))?; let rel = db::accepted_release(db, pkgbase)? .ok_or_else(|| Error::invalid(format!("{pkgbase} has no accepted release")))?; let identity = format!( diff --git a/src/pipeline/steps.rs b/src/pipeline/steps.rs index be4ebf3..ebb50c5 100644 --- a/src/pipeline/steps.rs +++ b/src/pipeline/steps.rs @@ -1,7 +1,7 @@ use std::path::Path; use crate::db::{self, builds, model::*}; -use crate::error::{Error, Result}; +use crate::error::{Error, Guard, Result, WorldGap}; use crate::git; use crate::pipeline::{Collect, CollectedPkg, Ctx, StepResult}; use crate::sandbox::Cmd; @@ -44,10 +44,11 @@ fn materialize(ctx: &Ctx) -> Result<StepResult> { git::materialize(&mirror, &ctx.src.aur_commit, &ctx.srcdir)?; let computed = sources::recipe_hash(&mirror, &ctx.src.aur_commit)?; if !ctx.src.recipe_hash.is_empty() && computed != ctx.src.recipe_hash { - return Err(Error::fail_closed(format!( - "recipe_hash mismatch: approved {}, materialized {}", - ctx.src.recipe_hash, computed - ))); + return Err(Error::fail_closed(Guard::HashMismatch { + what: "recipe_hash", + approved: ctx.src.recipe_hash.clone(), + computed, + })); } ctx.log_line(&format!( " materialized {} at {} (recipe_hash {})", @@ -112,10 +113,11 @@ fn provision(ctx: &Ctx) -> Result<StepResult> { let path = ctx.cfg.store_path(&e.digest); let (digest, _) = crate::hash::digest_file(&path)?; if digest != e.digest { - return Err(Error::fail_closed(format!( - "lease artifact {}-{}: store bytes hash to {digest} but the index says {}", - e.name, e.version, e.digest - ))); + return Err(Error::fail_closed(Guard::DigestMismatch { + url: format!("{}-{}", e.name, e.version), + expected: e.digest.clone(), + found: digest, + })); } let mut f = std::fs::File::open(&path)?; sbx.put(&e.digest, &mut f)?; @@ -148,10 +150,9 @@ fn provision(ctx: &Ctx) -> Result<StepResult> { .collect(); for e in &lease { if !installed.contains(&(e.name.clone(), e.version.clone())) { - return Err(Error::world_mismatch(format!( - "sandbox world is missing {}-{} after installing the lease set", - e.name, e.version - ))); + return Err(Error::world_mismatch(WorldGap::MissingPin { + package: format!("{}-{}", e.name, e.version), + })); } } ctx.log_line(&format!( |
