diff options
| author | aur-build <aur-build@localhost> | 2026-11-22 10:36:24 +0000 |
|---|---|---|
| committer | aur-build <aur-build@localhost> | 2026-11-22 10:36:24 +0000 |
| commit | 3dc71b2f5160ef9bd46143eed0edb5d2557b58e6 (patch) | |
| tree | 7cc7169181b4bdd73fd8817f8c1d7cce6e6998a8 /src/pipeline | |
| parent | 9dc9087d89891c6e5ef7e5dc084dd13c8611843e (diff) | |
| download | aur-build-3dc71b2f5160ef9bd46143eed0edb5d2557b58e6.tar.gz aur-build-3dc71b2f5160ef9bd46143eed0edb5d2557b58e6.zip | |
rustfmt,lints: pin the formatting, adopt the idiom lints, pay them off
rustfmt.toml fixes the shape the tree is written in (120 columns, small
items kept on one line) and one canonical pass makes it the truth.
[lints.clippy] names the idiom lints worth enforcing and leaves out the
two that would add doc-comment boilerplate rather than remove it. The
tree pays them off here: write!/writeln! instead of push_str(&format!()),
let-else instead of match-on-Option, borrows where a thread entry point
only reads what it owns, no `&self` on a Copy state and no `self` nobody
reads.
ops::to_prometheus gains one gauge helper: a metric's HELP, TYPE and
value are now emitted by the same call instead of three.
Diffstat (limited to 'src/pipeline')
| -rw-r--r-- | src/pipeline/dispatch.rs | 46 | ||||
| -rw-r--r-- | src/pipeline/mod.rs | 71 | ||||
| -rw-r--r-- | src/pipeline/publish.rs | 37 | ||||
| -rw-r--r-- | src/pipeline/steps.rs | 85 |
4 files changed, 85 insertions, 154 deletions
diff --git a/src/pipeline/dispatch.rs b/src/pipeline/dispatch.rs index 8e35f0a..b2d3933 100644 --- a/src/pipeline/dispatch.rs +++ b/src/pipeline/dispatch.rs @@ -26,26 +26,24 @@ impl Pool { let mut handles = Vec::new(); for n in 0..workers { - let cfg = cfg.clone(); + let cfg = Arc::clone(&cfg); let db = db.clone(); - let stop = stop.clone(); + let stop = Arc::clone(&stop); let rx = rx.clone(); handles.push( std::thread::Builder::new() .name(format!("worker-{n}")) - .spawn(crate::time::inherit(move || worker(cfg, db, rx, stop))) + .spawn(crate::time::inherit(move || worker(&cfg, &db, &rx, &stop))) .expect("spawn worker"), ); } drop(rx); - let cfg2 = cfg.clone(); - let db2 = db.clone(); - let stop2 = stop.clone(); + let dispatcher_stop = Arc::clone(&stop); handles.push( std::thread::Builder::new() .name("dispatcher".into()) - .spawn(crate::time::inherit(move || dispatcher(cfg2, db2, stop2, tx))) + .spawn(crate::time::inherit(move || dispatcher(&cfg, &db, &dispatcher_stop, &tx))) .expect("spawn dispatcher"), ); @@ -66,13 +64,13 @@ impl Pool { } } -fn dispatcher(cfg: Arc<Config>, db: Db, stop: Arc<AtomicBool>, tx: Sender<String>) { +fn dispatcher(cfg: &Config, db: &Db, stop: &AtomicBool, tx: &Sender<String>) { while !stop.load(Ordering::SeqCst) { - dispatch_once(&cfg, &db, &tx); + dispatch_once(cfg, db, tx); if !crate::time::wait( std::time::Duration::from_secs(cfg.dispatch_tick_secs), std::time::Duration::from_millis(200), - &stop, + stop, ) { break; } @@ -96,14 +94,7 @@ fn dispatch_once(cfg: &Config, db: &Db, tx: &Sender<String>) -> Vec<String> { fn dispatch_once_impl(cfg: &Config, db: &Db, tx: &Sender<String>) -> Vec<String> { let reaped = builds::reap_expired(db).unwrap_or(0); if reaped > 0 { - db::audit_system( - &db.writer, - "build.reaped", - "build", - "*", - serde_json::json!({"requeued": reaped}), - ) - .ok(); + db::audit_system(&db.writer, "build.reaped", "build", "*", serde_json::json!({"requeued": reaped})).ok(); } let _ = builds::requeue_blocked(db); let _ = builds::cancel_superseded(db); @@ -165,10 +156,7 @@ fn free_disk_mb(path: &std::path::Path) -> u64 { fn free_disk_mb_impl(path: &std::path::Path) -> u64 { use std::ffi::CString; - let c = match CString::new(path.as_os_str().to_string_lossy().as_bytes()) { - Ok(c) => c, - Err(_) => return u64::MAX, - }; + let Ok(c) = CString::new(path.as_os_str().to_string_lossy().as_bytes()) else { return u64::MAX }; let mut stat: libc::statvfs = unsafe { std::mem::zeroed() }; let rc = unsafe { libc::statvfs(c.as_ptr(), &mut stat) }; if rc != 0 { @@ -179,17 +167,17 @@ fn free_disk_mb_impl(path: &std::path::Path) -> u64 { avail * bsize / (1024 * 1024) } -fn worker(cfg: Arc<Config>, db: Db, rx: crossbeam_channel::Receiver<String>, stop: Arc<AtomicBool>) { - for id in rx.iter() { +fn worker(cfg: &Config, db: &Db, rx: &crossbeam_channel::Receiver<String>, stop: &AtomicBool) { + for id in rx { if stop.load(Ordering::SeqCst) { - let _ = builds::requeue_transient(&db, &id); + let _ = builds::requeue_transient(db, &id); continue; } - let attempt = builds::get(&db, &id).ok().flatten().map(|b| b.attempt).unwrap_or(1); - match pipeline::run(&cfg, &db, &id) { + let attempt = builds::get(db, &id).ok().flatten().map_or(1, |b| b.attempt); + match pipeline::run(cfg, db, &id) { Ok(Outcome::Failed { transient, .. }) => { if transient && attempt < cfg.max_transient_attempts { - let _ = builds::requeue_transient(&db, &id); + let _ = builds::requeue_transient(db, &id); db::audit_system( &db.writer, "build.retry", @@ -201,7 +189,7 @@ fn worker(cfg: Arc<Config>, db: Db, rx: crossbeam_channel::Receiver<String>, sto } } Ok(Outcome::Cancelled) => {} - Ok(Outcome::Blocked { .. }) | Ok(Outcome::Succeeded { .. }) | Err(_) => {} + Ok(Outcome::Blocked { .. } | Outcome::Succeeded { .. }) | Err(_) => {} } if stop.load(Ordering::SeqCst) { break; diff --git a/src/pipeline/mod.rs b/src/pipeline/mod.rs index 3e63a69..5bc7cdb 100644 --- a/src/pipeline/mod.rs +++ b/src/pipeline/mod.rs @@ -1,5 +1,5 @@ -pub mod publish; pub mod dispatch; +pub mod publish; mod steps; use std::path::PathBuf; @@ -7,9 +7,9 @@ use std::sync::Arc; use std::time::Duration; use crate::config::Config; -use crate::db::{self, builds, Db, Pkgbase}; -use crate::db::model::*; +use crate::db::model::{BuildState, CandidateRow, ReleaseRow, StepState}; use crate::db::SnapshotRow; +use crate::db::{self, builds, Db, Pkgbase}; use crate::error::{Error, Missing, Result}; use crate::sandbox::{Sandbox, SandboxBackend}; @@ -103,26 +103,17 @@ 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(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 { - Some(cid) => { - let c = crate::review::reads::candidate(db, cid)? - .ok_or_else(|| Error::not_found("candidate for build"))?; - 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 - .release_id - .ok_or_else(|| Error::invalid("build has neither candidate nor release"))?; - let r = db::release_by_id(db, rid)? - .ok_or_else(|| Error::not_found("release for rebuild"))?; - SourceIdentity::from_release(&r) - } + let build = builds::get(db, 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 = if let Some(cid) = build.candidate_id { + let c = crate::review::reads::candidate(db, cid)?.ok_or_else(|| Error::not_found("candidate for build"))?; + let snap = + db::snapshot_by_id(db, c.snapshot_id)?.ok_or_else(|| Error::not_found("snapshot for candidate"))?; + SourceIdentity::from_candidate(&c, &snap) + } else { + let rid = build.release_id.ok_or_else(|| Error::invalid("build has neither candidate nor release"))?; + let r = db::release_by_id(db, rid)?.ok_or_else(|| Error::not_found("release for rebuild"))?; + SourceIdentity::from_release(&r) }; let attempt = build.attempt; let profile = build.build_profile.clone(); @@ -231,20 +222,13 @@ fn run_with_impl(ctx: &Ctx) -> Result<Outcome> { Err(e) => { let transient = e.is_transient(); builds::finish_step(&ctx.db, &ctx.build.id, step, StepState::Failed, None, Some(&e.to_string()))?; - builds::set_state( - &ctx.db, - &ctx.build.id, - BuildState::Failed, - Some(&format!("{step}: {e}")), - )?; + builds::set_state(&ctx.db, &ctx.build.id, BuildState::Failed, Some(&format!("{step}: {e}")))?; ctx.log_line(&format!("!! {step} failed: {e}")); return Ok(Outcome::Failed { step: step.to_string(), error: e.to_string(), transient }); } } } - let release_id = ctx - .release_id() - .ok_or_else(|| Error::other("publish produced no release"))?; + let release_id = ctx.release_id().ok_or_else(|| Error::other("publish produced no release"))?; builds::set_state(&ctx.db, &ctx.build.id, BuildState::Succeeded, None)?; db::audit_system( &ctx.db.writer, @@ -263,8 +247,7 @@ impl Ctx { } pub fn enqueue_for_candidate(cfg: &Config, db: &Db, c: &CandidateRow) -> Result<String> { - let pb = db::get_pkgbase_by_id(db, c.pkgbase_id)? - .ok_or_else(|| Error::not_found("pkgbase"))?; + let pb = db::get_pkgbase_by_id(db, c.pkgbase_id)?.ok_or_else(|| Error::not_found("pkgbase"))?; let world = publish::index_world(db)?; let world_hash = crate::hash::canonical_json(&world)?; let id = builds::build_id(&pb.name, &c.identity_hash, &world_hash, &cfg.build_profile); @@ -274,19 +257,21 @@ 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(Missing::Pkgbase(pkgbase.to_string())))?; + let pb = db::get_pkgbase(db, 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!( "sha256:{}", - crate::hash::hex(crate::hash::canonical_json(&serde_json::json!({ - "aur_commit": rel.aur_commit, - "recipe_hash": rel.recipe_hash, - "upstream_pins": rel.pins(), - "source_digests": rel.digests(), - "requested": "manual_rebuild", - }))?.as_bytes()) + crate::hash::hex( + crate::hash::canonical_json(&serde_json::json!({ + "aur_commit": rel.aur_commit, + "recipe_hash": rel.recipe_hash, + "upstream_pins": rel.pins(), + "source_digests": rel.digests(), + "requested": "manual_rebuild", + }))? + .as_bytes() + ) ); let world = publish::index_world(db)?; let world_hash = crate::hash::canonical_json(&world)?; diff --git a/src/pipeline/publish.rs b/src/pipeline/publish.rs index d22b833..24b7cdb 100644 --- a/src/pipeline/publish.rs +++ b/src/pipeline/publish.rs @@ -166,20 +166,14 @@ fn commit_release(ctx: &Ctx, collect: &Collect) -> Result<i64> { _ => None, }; let approval_id = approval_id.or(inherited).ok_or_else(|| { - Error::fail_closed(format!( - "refusing to publish a {} build with no approval behind it", - ctx.build.kind - )) + Error::fail_closed(format!("refusing to publish a {} build with no approval behind it", ctx.build.kind)) })?; let build_id = ctx.build.id.clone(); let packages = collect.packages.clone(); let names: Vec<String> = packages.iter().map(|p| p.name.clone()).collect(); let src = ctx.src.clone(); - let world_id = builds::get(&ctx.db, &build_id) - .ok() - .flatten() - .and_then(|b| b.world_snapshot_id); + let world_id = builds::get(&ctx.db, &build_id).ok().flatten().and_then(|b| b.world_snapshot_id); let repo_id = db::repo_id(&ctx.db)?; let expected_base: Option<i64> = match ctx.build.kind.as_str() { "manual_rebuild" => ctx.build.release_id, @@ -193,9 +187,7 @@ fn commit_release(ctx: &Ctx, collect: &Collect) -> Result<i64> { ctx.db.writer.tx(move |tx| { let actual_base = db::accepted_pointer_in(tx, pkgbase_id)?; if actual_base != expected_base { - return Err(Error::conflict( - "accepted pointer moved while this build was running; refusing to publish", - )); + return Err(Error::conflict("accepted pointer moved while this build was running; refusing to publish")); } db::remove_index_packages_in(tx, &names)?; let release_id = db::insert_release_in( @@ -220,9 +212,7 @@ fn commit_release(ctx: &Ctx, collect: &Collect) -> Result<i64> { db::insert_package_in(tx, repo_id, release_id, &p.name, &p.arch, &p.version, &p.digest)?; } if !db::cas_accepted_release_in(tx, pkgbase_id, release_id, expected_base)? { - return Err(Error::conflict( - "accepted pointer moved while this build was running; refusing to publish", - )); + return Err(Error::conflict("accepted pointer moved while this build was running; refusing to publish")); } builds::set_release_in(tx, &build_id, release_id)?; if let Some(cid) = candidate_id { @@ -334,18 +324,14 @@ pub(crate) fn sign_to(cfg: &Config, path: &Path, sig_out: &Path) -> Result<()> { } fn fsync_file(p: &Path) -> Result<()> { - let f = std::fs::File::open(p) - .map_err(|e| Error::other(format!("open {} for fsync: {e}", p.display())))?; - f.sync_all() - .map_err(|e| Error::other(format!("fsync {}: {e}", p.display())))?; + let f = std::fs::File::open(p).map_err(|e| Error::other(format!("open {} for fsync: {e}", p.display())))?; + f.sync_all().map_err(|e| Error::other(format!("fsync {}: {e}", p.display())))?; Ok(()) } fn fsync_dir(p: &Path) -> Result<()> { - let d = std::fs::File::open(p) - .map_err(|e| Error::other(format!("open dir {} for fsync: {e}", p.display())))?; - d.sync_all() - .map_err(|e| Error::other(format!("fsync dir {}: {e}", p.display())))?; + let d = std::fs::File::open(p).map_err(|e| Error::other(format!("open dir {} for fsync: {e}", p.display())))?; + d.sync_all().map_err(|e| Error::other(format!("fsync dir {}: {e}", p.display())))?; Ok(()) } @@ -353,11 +339,8 @@ fn dedupe_by_name(paths: Vec<PathBuf>) -> Vec<PathBuf> { let mut seen: BTreeSet<String> = BTreeSet::new(); let mut out: Vec<PathBuf> = Vec::new(); for p in paths.into_iter().rev() { - let name = package_name(&p).unwrap_or_else(|| { - p.file_name() - .map(|s| s.to_string_lossy().into_owned()) - .unwrap_or_default() - }); + let name = + package_name(&p).unwrap_or_else(|| p.file_name().map_or_default(|s| s.to_string_lossy().into_owned())); if seen.insert(name) { out.push(p); } diff --git a/src/pipeline/steps.rs b/src/pipeline/steps.rs index 775485d..9703d54 100644 --- a/src/pipeline/steps.rs +++ b/src/pipeline/steps.rs @@ -1,6 +1,9 @@ use std::path::Path; -use crate::db::{self, builds, model::*}; +use crate::db::{ + self, builds, + model::{Recipe, SourceDigest, WorldMember}, +}; use crate::error::{Error, Guard, Result, WorldGap}; use crate::git; use crate::pipeline::{Collect, CollectedPkg, Ctx, StepResult}; @@ -29,8 +32,7 @@ fn materialize(ctx: &Ctx) -> Result<StepResult> { .mirror_path .as_ref() .map(Path::new) - .map(|p| p.to_path_buf()) - .unwrap_or_else(|| ctx.cfg.mirror_path(&ctx.pb.name)); + .map_or_else(|| ctx.cfg.mirror_path(&ctx.pb.name), std::path::Path::to_path_buf); if !mirror.exists() { return Err(Error::fail_closed(format!( "mirror {} missing; refusing to fetch a recipe from the network at build time", @@ -105,10 +107,7 @@ fn provision(ctx: &Ctx) -> Result<StepResult> { if lease.is_empty() { return Ok(StepResult::Skipped("no of-our-packages dependencies to install".into())); } - let sbx = match sandbox_or_wait(ctx)? { - Some(s) => s, - None => return Ok(StepResult::Blocked(vec!["sandbox-pool".into()])), - }; + let Some(sbx) = sandbox_or_wait(ctx)? else { return Ok(StepResult::Blocked(vec!["sandbox-pool".into()])) }; for e in &lease { let path = ctx.cfg.store_path(&e.digest); let (digest, _) = crate::hash::digest_file(&path)?; @@ -134,11 +133,7 @@ fn provision(ctx: &Ctx) -> Result<StepResult> { } let q = sbx.run(&Cmd::new(vec![ctx.cfg.pacman_bin.clone(), "-Q".into()]), &mut |_| {})?; if !q.success() { - return Err(Error::fail_closed(format!( - "{} -Q failed: {}", - ctx.cfg.pacman_bin, - tail(&q.stderr) - ))); + return Err(Error::fail_closed(format!("{} -Q failed: {}", ctx.cfg.pacman_bin, tail(&q.stderr)))); } let installed: std::collections::BTreeSet<(String, String)> = String::from_utf8_lossy(&q.stdout) .lines() @@ -150,9 +145,7 @@ 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(WorldGap::MissingPin { - package: format!("{}-{}", e.name, e.version), - })); + return Err(Error::world_mismatch(WorldGap::MissingPin { package: format!("{}-{}", e.name, e.version) })); } } ctx.log_line(&format!( @@ -164,9 +157,7 @@ fn provision(ctx: &Ctx) -> Result<StepResult> { Ok(StepResult::Done(Some(crate::hash::canonical_json(&world)?))) } -fn sandbox_or_wait( - ctx: &Ctx, -) -> Result<Option<std::sync::Arc<dyn crate::sandbox::Sandbox>>> { +fn sandbox_or_wait(ctx: &Ctx) -> Result<Option<std::sync::Arc<dyn crate::sandbox::Sandbox>>> { match ctx.sandbox() { Ok(s) => Ok(Some(s)), Err(e) if e.is_pool_exhausted() => { @@ -218,14 +209,12 @@ fn sources(ctx: &Ctx) -> Result<StepResult> { } } ctx.log_line(&format!(" {}/{} source digests verified", verified, digests.len())); - Ok(StepResult::Done(Some(crate::hash::hex_str( - &ctx.src.source_digests_json, - )))) + Ok(StepResult::Done(Some(crate::hash::hex_str(&ctx.src.source_digests_json)))) } fn pkgver(ctx: &Ctx) -> Result<StepResult> { let recipe = recipe_at(&ctx.srcdir)?; - let has_vcs = recipe.source_entries.iter().any(|s| s.is_vcs()); + let has_vcs = recipe.source_entries.iter().any(super::super::db::model::SourceEntry::is_vcs); if !has_vcs { let want = (ctx.src.pkgver.clone(), ctx.src.pkgrel.clone()); let got = (recipe.pkgver.clone(), recipe.pkgrel.clone()); @@ -263,10 +252,7 @@ fn pkgver(ctx: &Ctx) -> Result<StepResult> { fn build(ctx: &Ctx) -> Result<StepResult> { let argv = vec![ctx.cfg.makepkg_bin.clone(), "-c".into(), "-f".into()]; - let sbx = match sandbox_or_wait(ctx)? { - Some(s) => s, - None => return Ok(StepResult::Blocked(vec!["sandbox-pool".into()])), - }; + let Some(sbx) = sandbox_or_wait(ctx)? else { return Ok(StepResult::Blocked(vec!["sandbox-pool".into()])) }; if let Some(parent) = ctx.log.parent() { let _ = std::fs::create_dir_all(parent); } @@ -280,15 +266,9 @@ fn build(ctx: &Ctx) -> Result<StepResult> { let out = sbx.run(&Cmd::new(argv).in_dir(&ctx.srcdir), &mut on_log)?; drop(on_log); if !out.success() { - return Err(Error::Subprocess { - cmd: ctx.cfg.makepkg_bin.clone(), - detail: tail(&out.stderr), - }); + return Err(Error::Subprocess { cmd: ctx.cfg.makepkg_bin.clone(), detail: tail(&out.stderr) }); } - Ok(StepResult::Done(Some(crate::hash::hex_str(&format!( - "build:{}", - ctx.build.id - ))))) + Ok(StepResult::Done(Some(crate::hash::hex_str(&format!("build:{}", ctx.build.id))))) } fn tail(b: &[u8]) -> String { @@ -300,14 +280,14 @@ fn tail(b: &[u8]) -> String { fn collect(ctx: &Ctx) -> Result<StepResult> { let mut pkgs = Vec::new(); let mut entries: Vec<PathBuf> = std::fs::read_dir(&ctx.srcdir)? - .filter_map(|e| e.ok()) + .filter_map(std::result::Result::ok) .map(|e| e.path()) .filter(|p| p.to_string_lossy().ends_with(".pkg.tar.zst")) .collect(); entries.sort(); let staging_root = ctx.staging.canonicalize()?; for path in entries { - if std::fs::symlink_metadata(&path).map(|m| m.file_type().is_symlink()).unwrap_or(true) { + if std::fs::symlink_metadata(&path).map_or(true, |m| m.file_type().is_symlink()) { return Err(Error::fail_closed(format!( "{} is a symlink; a build may not smuggle bytes in from outside its own staging dir", path.display() @@ -316,15 +296,16 @@ fn collect(ctx: &Ctx) -> Result<StepResult> { let resolved = path.canonicalize()?; if !resolved.starts_with(&staging_root) { return Err(Error::fail_closed(format!( - "{} resolves outside this build's staging dir ({staging_root:?}); refusing to ingest it", - path.display() + "{} resolves outside this build's staging dir ({}); refusing to ingest it", + path.display(), + staging_root.display() ))); } let path = resolved; let bytes = std::fs::read(&path)?; let (digest, size) = crate::hash::digest_file(&path)?; - let pkginfo = crate::pkginfo::pkginfo_text(&bytes) - .map_err(|e| Error::invalid(format!("{}: {e}", path.display())))?; + let pkginfo = + crate::pkginfo::pkginfo_text(&bytes).map_err(|e| Error::invalid(format!("{}: {e}", path.display())))?; let meta = crate::pkginfo::parse_pkginfo(&pkginfo); let buildinfo = crate::pkginfo::buildinfo_text(&bytes).unwrap_or_default(); let sig = path.with_extension("pkg.tar.zst.sig"); @@ -340,10 +321,7 @@ fn collect(ctx: &Ctx) -> Result<StepResult> { makedepends: meta.makedepends.clone(), provides: meta.provides.clone(), conflicts: meta.conflicts.clone(), - installed: crate::pkginfo::parse_installed(&buildinfo) - .into_iter() - .map(|i| (i.name, i.version)) - .collect(), + installed: crate::pkginfo::parse_installed(&buildinfo).into_iter().map(|i| (i.name, i.version)).collect(), }); } if pkgs.is_empty() { @@ -351,7 +329,10 @@ fn collect(ctx: &Ctx) -> Result<StepResult> { } let collect = Collect { packages: pkgs.clone() }; collect.save(&ctx.collect_path)?; - ctx.log_line(&format!(" collected {}", pkgs.iter().map(|p| format!("{}-{}", p.name, p.version)).collect::<Vec<_>>().join(", "))); + ctx.log_line(&format!( + " collected {}", + pkgs.iter().map(|p| format!("{}-{}", p.name, p.version)).collect::<Vec<_>>().join(", ") + )); Ok(StepResult::Done(Some(crate::hash::hex_str(&serde_json::to_string(&pkgs)?)))) } @@ -359,10 +340,8 @@ fn verify(ctx: &Ctx) -> Result<StepResult> { let collect = Collect::load(&ctx.collect_path)?; let ours = db::our_package_names(&ctx.db)?; for p in &collect.packages { - if crate::pkgver::is_downgrade( - &db::index_version(&ctx.db, &p.name)?.unwrap_or_else(|| "0".into()), - &p.version, - ) { + if crate::pkgver::is_downgrade(&db::index_version(&ctx.db, &p.name)?.unwrap_or_else(|| "0".into()), &p.version) + { ctx.log_line(&format!(" note: {} is a downgrade from what we serve", p.name)); } let mut provided: std::collections::BTreeSet<String> = ours.clone(); @@ -439,10 +418,7 @@ fn ingest(ctx: &Ctx) -> Result<StepResult> { let world_id = db::put_world_snapshot(&ctx.db.writer, &members)?; builds::set_world(&ctx.db, &ctx.build.id, world_id)?; ctx.log_line(&format!(" ingested {} artifact(s), world has {} of our packages", packages.len(), members.len())); - Ok(StepResult::Done(Some(crate::hash::hex_str(&format!( - "ingest:{}", - packages.len() - ))))) + Ok(StepResult::Done(Some(crate::hash::hex_str(&format!("ingest:{}", packages.len()))))) } fn publish(ctx: &Ctx) -> Result<StepResult> { @@ -456,7 +432,7 @@ use std::path::PathBuf; fn recipe_at(dir: &Path) -> Result<Recipe> { let mut files = std::collections::BTreeMap::new(); - for entry in walkdir::WalkDir::new(dir).max_depth(2).into_iter().filter_map(|e| e.ok()) { + for entry in walkdir::WalkDir::new(dir).max_depth(2).into_iter().filter_map(std::result::Result::ok) { let p = entry.path(); if !p.is_file() { continue; @@ -468,4 +444,3 @@ fn recipe_at(dir: &Path) -> Result<Recipe> { } crate::recipe::recipe_from_tree(&files) } - |
