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/db/builds/steps.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/db/builds/steps.rs')
| -rw-r--r-- | src/db/builds/steps.rs | 54 |
1 files changed, 17 insertions, 37 deletions
diff --git a/src/db/builds/steps.rs b/src/db/builds/steps.rs index 4ffff36..01faa03 100644 --- a/src/db/builds/steps.rs +++ b/src/db/builds/steps.rs @@ -17,9 +17,8 @@ pub struct StepRow { pub fn steps(db: &Db, id: &str) -> Result<Vec<StepRow>> { let id = id.to_string(); db.read(move |c| { - let mut stmt = c.prepare( - "SELECT step, status, attempt, error FROM build_step WHERE build_id=?1 ORDER BY rowid", - )?; + let mut stmt = + c.prepare("SELECT step, status, attempt, error FROM build_step WHERE build_id=?1 ORDER BY rowid")?; let rows = stmt.query_map(params![id], |r| { Ok(StepRow { step: r.get(0)?, @@ -39,11 +38,9 @@ pub fn steps(db: &Db, id: &str) -> Result<Vec<StepRow>> { pub fn step_status(db: &Db, build_id: &str, step: &str) -> Result<Option<StepState>> { let (b, s) = (build_id.to_string(), step.to_string()); db.read(move |c| { - c.query_row( - "SELECT status FROM build_step WHERE build_id=?1 AND step=?2", - params![b, s], - |r| crate::db::state_col::<StepState>(0, &r.get::<_, String>(0)?), - ) + c.query_row("SELECT status FROM build_step WHERE build_id=?1 AND step=?2", params![b, s], |r| { + crate::db::state_col::<StepState>(0, &r.get::<_, String>(0)?) + }) .optional() .map_err(Into::into) }) @@ -80,8 +77,8 @@ pub fn finish_step( error: Option<&str>, ) -> Result<()> { let (b, s) = (build_id.to_string(), step.to_string()); - let od = output_digest.map(|s| s.to_string()); - let err = error.map(|s| s.to_string()); + let od = output_digest.map(std::string::ToString::to_string); + let err = error.map(std::string::ToString::to_string); let at = time::now(); let froms = StepState::predecessors(to); let placeholders = froms.iter().map(|_| "?").collect::<Vec<_>>().join(","); @@ -98,16 +95,10 @@ pub fn finish_step( let n = tx.execute(&sql, rusqlite::params_from_iter(args))?; if n == 0 { let was: Option<String> = tx - .query_row( - "SELECT status FROM build_step WHERE build_id=?1 AND step=?2", - params![b, s], - |r| r.get(0), - ) + .query_row("SELECT status FROM build_step WHERE build_id=?1 AND step=?2", params![b, s], |r| r.get(0)) .optional()?; return Err(match was { - Some(w) => Error::invalid(format!( - "illegal step transition {w} → {to} for step {s} of build {b}" - )), + Some(w) => Error::invalid(format!("illegal step transition {w} → {to} for step {s} of build {b}")), None => Error::invalid(format!("no checkpoint for step {s} of build {b}")), }); } @@ -117,18 +108,15 @@ pub fn finish_step( pub fn in_flight(db: &Db) -> Result<usize> { db.read(|c| { - Ok(c.query_row( - "SELECT count(*) FROM build WHERE state IN ('leased','running')", - [], - |r| r.get::<_, i64>(0), - )? as usize) + Ok(c.query_row("SELECT count(*) FROM build WHERE state IN ('leased','running')", [], |r| r.get::<_, i64>(0))? + as usize) }) } pub fn queue_depth(db: &Db) -> Result<usize> { - db.read(|c| { - Ok(c.query_row("SELECT count(*) FROM build WHERE state='queued'", [], |r| r.get::<_, i64>(0))? as usize) - }) + db.read( + |c| Ok(c.query_row("SELECT count(*) FROM build WHERE state='queued'", [], |r| r.get::<_, i64>(0))? as usize), + ) } pub fn blocked_builds(db: &Db) -> Result<Vec<(String, String, Vec<String>)>> { @@ -137,9 +125,8 @@ pub fn blocked_builds(db: &Db) -> Result<Vec<(String, String, Vec<String>)>> { "SELECT b.id, p.name, b.blocked_on_json FROM build b JOIN pkgbase p ON p.id = b.pkgbase_id WHERE b.state='blocked_missing_dep'", )?; - let rows = stmt.query_map([], |r| { - Ok((r.get::<_, String>(0)?, r.get::<_, String>(1)?, r.get::<_, String>(2)?)) - })?; + let rows = + stmt.query_map([], |r| Ok((r.get::<_, String>(0)?, r.get::<_, String>(1)?, r.get::<_, String>(2)?)))?; let mut out = Vec::new(); for r in rows { let (id, name, json) = r?; @@ -154,7 +141,6 @@ pub fn set_release_in(tx: &rusqlite::Transaction<'_>, id: &str, release_id: i64) Ok(()) } - pub fn set_world(db: &Db, id: &str, world_id: i64) -> Result<()> { let id = id.to_string(); db.writer.tx(move |tx| { @@ -163,10 +149,6 @@ pub fn set_world(db: &Db, id: &str, world_id: i64) -> Result<()> { }) } - - - - pub fn set_blocked_on(db: &Db, id: &str, blocked_on: &[String]) -> Result<()> { let id = id.to_string(); let json = serde_json::to_string(blocked_on)?; @@ -176,7 +158,6 @@ pub fn set_blocked_on(db: &Db, id: &str, blocked_on: &[String]) -> Result<()> { }) } - pub fn claim_batch(db: &Db, owner: &str, limit: usize, lease_secs: i64) -> Result<Vec<String>> { if limit == 0 { return Ok(Vec::new()); @@ -219,8 +200,7 @@ pub fn cancel_superseded(db: &Db) -> Result<usize> { pub fn requeue_transient(db: &Db, id: &str) -> Result<()> { let id = id.to_string(); - db.writer - .tx(move |tx| transition_in_tx(tx, &id, BuildState::Queued, None)) + db.writer.tx(move |tx| transition_in_tx(tx, &id, BuildState::Queued, None)) } pub fn retry(db: &Db, id: &str) -> Result<()> { |
