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/pkgbases.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/pkgbases.rs')
| -rw-r--r-- | src/db/pkgbases.rs | 37 |
1 files changed, 9 insertions, 28 deletions
diff --git a/src/db/pkgbases.rs b/src/db/pkgbases.rs index 743aa43..909291f 100644 --- a/src/db/pkgbases.rs +++ b/src/db/pkgbases.rs @@ -1,6 +1,6 @@ use rusqlite::{params, OptionalExtension, Row}; -use crate::db::*; +use crate::db::{release_by_id, Db, ReleaseRow, Writer}; use crate::error::Result; // ---------------------------------------------------------------- pkgbase -- @@ -33,25 +33,17 @@ const PKGBASE_COLS: &str = "id, name, aur_url, mirror_path, aur_head, \ pub fn get_pkgbase(db: &Db, name: &str) -> Result<Option<Pkgbase>> { db.read(|c| { - c.query_row( - &format!("SELECT {PKGBASE_COLS} FROM pkgbase WHERE name = ?1"), - params![name], - row_to_pkgbase, - ) - .optional() - .map_err(Into::into) + c.query_row(&format!("SELECT {PKGBASE_COLS} FROM pkgbase WHERE name = ?1"), params![name], row_to_pkgbase) + .optional() + .map_err(Into::into) }) } pub fn get_pkgbase_by_id(db: &Db, id: i64) -> Result<Option<Pkgbase>> { db.read(|c| { - c.query_row( - &format!("SELECT {PKGBASE_COLS} FROM pkgbase WHERE id = ?1"), - params![id], - row_to_pkgbase, - ) - .optional() - .map_err(Into::into) + c.query_row(&format!("SELECT {PKGBASE_COLS} FROM pkgbase WHERE id = ?1"), params![id], row_to_pkgbase) + .optional() + .map_err(Into::into) }) } @@ -66,19 +58,14 @@ pub fn accepted_release_for(db: &Db, pb: &Pkgbase) -> Result<Option<ReleaseRow>> } } - pub fn set_aur_head(writer: &Writer, pkgbase_id: i64, head: &str, mirror: &str) -> Result<()> { let (h, m) = (head.to_string(), mirror.to_string()); writer.tx(move |tx| { - tx.execute( - "UPDATE pkgbase SET aur_head=?1, mirror_path=?2 WHERE id=?3", - params![h, m, pkgbase_id], - )?; + tx.execute("UPDATE pkgbase SET aur_head=?1, mirror_path=?2 WHERE id=?3", params![h, m, pkgbase_id])?; Ok(()) }) } - /// Compare-and-set the accepted-release pointer. /// /// Test-tier only, and the reason is worth keeping next to it: production @@ -89,12 +76,7 @@ pub fn set_aur_head(writer: &Writer, pkgbase_id: i64, head: &str, mirror: &str) /// names differ by three characters, which is exactly how a name-match census /// once credited this function with a production caller it never had. #[cfg(feature = "test-support")] -pub fn cas_accepted_release( - writer: &Writer, - pkgbase_id: i64, - expected: Option<i64>, - new_id: i64, -) -> Result<bool> { +pub fn cas_accepted_release(writer: &Writer, pkgbase_id: i64, expected: Option<i64>, new_id: i64) -> Result<bool> { writer.tx(move |tx| { let n = tx.execute( "UPDATE pkgbase SET current_accepted_release_id=?1 @@ -104,4 +86,3 @@ pub fn cas_accepted_release( Ok(n == 1) }) } - |
