summaryrefslogtreecommitdiffstats
path: root/src/db/snapshots.rs
diff options
context:
space:
mode:
authoraur-build <aur-build@localhost>2026-11-22 10:36:24 +0000
committeraur-build <aur-build@localhost>2026-11-22 10:36:24 +0000
commit3dc71b2f5160ef9bd46143eed0edb5d2557b58e6 (patch)
tree7cc7169181b4bdd73fd8817f8c1d7cce6e6998a8 /src/db/snapshots.rs
parent9dc9087d89891c6e5ef7e5dc084dd13c8611843e (diff)
downloadaur-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/snapshots.rs')
-rw-r--r--src/db/snapshots.rs34
1 files changed, 9 insertions, 25 deletions
diff --git a/src/db/snapshots.rs b/src/db/snapshots.rs
index 7966c8b..144cb0d 100644
--- a/src/db/snapshots.rs
+++ b/src/db/snapshots.rs
@@ -1,6 +1,6 @@
use rusqlite::{params, OptionalExtension};
-use crate::db::*;
+use crate::db::{Db, Writer};
use crate::error::Result;
use crate::time;
@@ -15,12 +15,8 @@ pub fn put_snapshot(
srcinfo_json: &str,
files_json: &str,
) -> Result<i64> {
- let (c, rh, si, fj) = (
- aur_commit.to_string(),
- recipe_hash.to_string(),
- srcinfo_json.to_string(),
- files_json.to_string(),
- );
+ let (c, rh, si, fj) =
+ (aur_commit.to_string(), recipe_hash.to_string(), srcinfo_json.to_string(), files_json.to_string());
let at = time::now();
writer.tx(move |tx| {
tx.execute(
@@ -29,11 +25,9 @@ pub fn put_snapshot(
ON CONFLICT(pkgbase_id, aur_commit) DO NOTHING",
params![pkgbase_id, c, rh, si, fj, at],
)?;
- tx.query_row(
- "SELECT id FROM snapshot WHERE pkgbase_id=?1 AND aur_commit=?2",
- params![pkgbase_id, c],
- |r| r.get(0),
- )
+ tx.query_row("SELECT id FROM snapshot WHERE pkgbase_id=?1 AND aur_commit=?2", params![pkgbase_id, c], |r| {
+ r.get(0)
+ })
.map_err(Into::into)
})
}
@@ -73,20 +67,10 @@ pub fn snapshot_by_commit(db: &Db, pkgbase_id: i64, commit: &str) -> Result<Opti
pub fn snapshot_by_id(db: &Db, id: i64) -> Result<Option<SnapshotRow>> {
db.read(|c| {
- c.query_row(
- "SELECT id, aur_commit, recipe_hash, srcinfo_json FROM snapshot WHERE id=?1",
- params![id],
- |r| {
- Ok(SnapshotRow {
- id: r.get(0)?,
- aur_commit: r.get(1)?,
- recipe_hash: r.get(2)?,
- srcinfo_json: r.get(3)?,
- })
- },
- )
+ c.query_row("SELECT id, aur_commit, recipe_hash, srcinfo_json FROM snapshot WHERE id=?1", params![id], |r| {
+ Ok(SnapshotRow { id: r.get(0)?, aur_commit: r.get(1)?, recipe_hash: r.get(2)?, srcinfo_json: r.get(3)? })
+ })
.optional()
.map_err(Into::into)
})
}
-