summaryrefslogtreecommitdiffstats
path: root/src/db/pkgbases.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/db/pkgbases.rs')
-rw-r--r--src/db/pkgbases.rs37
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)
})
}
-