diff --git a/src/build_queue.rs b/src/build_queue.rs index bc7951b26..a0492304e 100644 --- a/src/build_queue.rs +++ b/src/build_queue.rs @@ -176,12 +176,8 @@ impl BuildQueue { }) } - pub(crate) async fn has_build_queued( - &self, - conn: &mut sqlx::PgConnection, - name: &str, - version: &str, - ) -> Result { + pub(crate) async fn has_build_queued(&self, name: &str, version: &str) -> Result { + let mut conn = self.db.get_async().await?; Ok(sqlx::query_scalar!( "SELECT id FROM queue @@ -501,7 +497,7 @@ impl BuildQueue { update_latest_version_id(&mut *conn, crate_id).await?; } else { match self - .has_build_queued(&mut *conn, name, version) + .has_build_queued(name, version) .await .context("error trying to fetch build queue") { @@ -678,20 +674,14 @@ mod tests { queue.add_crate("dummy", "0.1.1", 0, None)?; env.runtime().block_on(async { let mut conn = env.async_db().await.async_conn().await; - assert!(queue - .has_build_queued(&mut conn, "dummy", "0.1.1") - .await - .unwrap()); + assert!(queue.has_build_queued("dummy", "0.1.1").await.unwrap()); sqlx::query!("UPDATE queue SET attempt = 6") .execute(&mut *conn) .await .unwrap(); - assert!(!queue - .has_build_queued(&mut conn, "dummy", "0.1.1") - .await - .unwrap()); + assert!(!queue.has_build_queued("dummy", "0.1.1").await.unwrap()); }); Ok(()) diff --git a/src/web/builds.rs b/src/web/builds.rs index ba0065656..a1e5d67a9 100644 --- a/src/web/builds.rs +++ b/src/web/builds.rs @@ -160,7 +160,7 @@ async fn build_trigger_check( } let crate_version_is_in_queue = build_queue - .has_build_queued(&mut *conn, name, &version.to_string()) + .has_build_queued(name, &version.to_string()) .await?; if crate_version_is_in_queue { @@ -268,10 +268,9 @@ mod tests { fn has_build_queued(env: &TestEnvironment, name: &str, version: &str) -> anyhow::Result { env.runtime().block_on(async move { - let mut conn = env.async_db().await.async_conn().await; let build_queue = env.build_queue(); - build_queue.has_build_queued(&mut conn, name, version).await + build_queue.has_build_queued(name, version).await }) }