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/publish.rs | |
| 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/publish.rs')
| -rw-r--r-- | src/pipeline/publish.rs | 37 |
1 files changed, 10 insertions, 27 deletions
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); } |
