summaryrefslogtreecommitdiffstats
path: root/src/pipeline/publish.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/pipeline/publish.rs')
-rw-r--r--src/pipeline/publish.rs37
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);
}