summaryrefslogtreecommitdiffstats
path: root/src/db/snapshots.rs
diff options
context:
space:
mode:
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)
})
}
-