treewide: address all clippy lints
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I5cf55cc4cb558c3f9f764c71224e87176a6a6964
This commit is contained in:
parent
967d51e867
commit
0ca92f2710
63 changed files with 1788 additions and 1087 deletions
|
|
@ -6,6 +6,11 @@ use crate::{
|
|||
models::BuildStatus,
|
||||
};
|
||||
|
||||
/// Check if a derivation path is in the failed paths cache.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// Returns error if database query fails.
|
||||
pub async fn is_cached_failure(pool: &PgPool, drv_path: &str) -> Result<bool> {
|
||||
let row: Option<(bool,)> =
|
||||
sqlx::query_as("SELECT true FROM failed_paths_cache WHERE drv_path = $1")
|
||||
|
|
@ -17,6 +22,11 @@ pub async fn is_cached_failure(pool: &PgPool, drv_path: &str) -> Result<bool> {
|
|||
Ok(row.is_some())
|
||||
}
|
||||
|
||||
/// Insert a failed derivation path into the cache.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// Returns error if database insert fails.
|
||||
pub async fn insert(
|
||||
pool: &PgPool,
|
||||
drv_path: &str,
|
||||
|
|
@ -40,6 +50,11 @@ pub async fn insert(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Remove a derivation path from the failed paths cache.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// Returns error if database delete fails.
|
||||
pub async fn invalidate(pool: &PgPool, drv_path: &str) -> Result<()> {
|
||||
sqlx::query("DELETE FROM failed_paths_cache WHERE drv_path = $1")
|
||||
.bind(drv_path)
|
||||
|
|
@ -50,6 +65,11 @@ pub async fn invalidate(pool: &PgPool, drv_path: &str) -> Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Remove expired entries from the failed paths cache.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// Returns error if database delete fails.
|
||||
pub async fn cleanup_expired(pool: &PgPool, ttl_seconds: u64) -> Result<u64> {
|
||||
let result = sqlx::query(
|
||||
"DELETE FROM failed_paths_cache WHERE failed_at < NOW() - \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue