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/staleness.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/staleness.rs')
| -rw-r--r-- | src/db/staleness.rs | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/src/db/staleness.rs b/src/db/staleness.rs index 59fccee..58be227 100644 --- a/src/db/staleness.rs +++ b/src/db/staleness.rs @@ -1,6 +1,6 @@ use rusqlite::{params, OptionalExtension}; -use crate::db::*; +use crate::db::{Db, Writer}; use crate::error::Result; use crate::time; @@ -33,11 +33,7 @@ pub fn served_vs_offered_pkgvers(db: &Db) -> Result<Vec<(String, String, String) WHERE r.state = 'published'", )?; let rows = st.query_map([], |r| { - Ok(( - r.get::<_, String>(0)?, - r.get::<_, String>(1)?, - r.get::<_, Option<String>>(2)?.unwrap_or_default(), - )) + Ok((r.get::<_, String>(0)?, r.get::<_, String>(1)?, r.get::<_, Option<String>>(2)?.unwrap_or_default())) })?; Ok(rows.collect::<::rusqlite::Result<Vec<_>>>()?) }) @@ -63,10 +59,12 @@ pub fn index_recipes(db: &Db) -> Result<Vec<(String, String)>> { pub fn approval_note(db: &Db, approval_id: i64) -> Result<String> { db.read(|c| { - c.query_row("SELECT COALESCE(note,'') FROM approval WHERE id=?1", params![approval_id], |r| r.get::<_, String>(0)) - .optional() - .map(|o| o.unwrap_or_default()) - .map_err(Into::into) + c.query_row("SELECT COALESCE(note,'') FROM approval WHERE id=?1", params![approval_id], |r| { + r.get::<_, String>(0) + }) + .optional() + .map(std::option::Option::unwrap_or_default) + .map_err(Into::into) }) } @@ -77,7 +75,6 @@ pub fn candidate_snapshot_id(db: &Db, candidate_id: i64) -> Result<Option<i64>> }) } - pub fn put_source_cache(writer: &Writer, url: &str, digest: &str, size: u64, path: &str) -> Result<()> { let (u, d, p) = (url.to_string(), digest.to_string(), path.to_string()); let at = time::now(); @@ -93,11 +90,9 @@ pub fn put_source_cache(writer: &Writer, url: &str, digest: &str, size: u64, pat pub fn source_cache_path(db: &Db, url: &str, digest: &str) -> Result<Option<String>> { db.read(|c| { - Ok(c.query_row( - "SELECT path FROM source_cache WHERE url=?1 AND digest=?2", - params![url, digest], - |r| r.get::<_, String>(0), - ) + Ok(c.query_row("SELECT path FROM source_cache WHERE url=?1 AND digest=?2", params![url, digest], |r| { + r.get::<_, String>(0) + }) .optional()?) }) } @@ -121,4 +116,3 @@ pub fn insert_artifact_in(tx: &rusqlite::Transaction<'_>, a: &NewArtifact<'_>) - )?; Ok(()) } - |
