@@ -130,7 +130,7 @@ pub(crate) async fn build_list_json_handler(
130130}
131131
132132async fn crate_version_exists (
133- mut conn : DbConnection ,
133+ conn : & mut sqlx :: PgConnection ,
134134 name : & String ,
135135 version : & Version ,
136136) -> Result < bool , anyhow:: Error > {
@@ -150,22 +150,19 @@ async fn crate_version_exists(
150150}
151151
152152async fn build_trigger_check (
153- conn : DbConnection ,
153+ conn : & mut sqlx :: PgConnection ,
154154 name : & String ,
155155 version : & Version ,
156156 build_queue : & Arc < BuildQueue > ,
157157) -> AxumResult < impl IntoResponse > {
158- if !crate_version_exists ( conn, name, version) . await ? {
158+ if !crate_version_exists ( & mut * conn, name, version) . await ? {
159159 return Err ( AxumNope :: VersionNotFound ) ;
160160 }
161161
162- let crate_version_is_in_queue = spawn_blocking ( {
163- let name = name. clone ( ) ;
164- let version_string = version. to_string ( ) ;
165- let build_queue = build_queue. clone ( ) ;
166- move || build_queue. has_build_queued ( & name, & version_string)
167- } )
168- . await ?;
162+ let crate_version_is_in_queue = build_queue
163+ . has_build_queued ( & mut * conn, & name, & version. to_string ( ) )
164+ . await ?;
165+
169166 if crate_version_is_in_queue {
170167 return Err ( AxumNope :: BadRequest ( anyhow ! (
171168 "crate {name} {version} already queued for rebuild"
@@ -181,7 +178,7 @@ const TRIGGERED_REBUILD_PRIORITY: i32 = 5;
181178
182179pub ( crate ) async fn build_trigger_rebuild_handler (
183180 Path ( ( name, version) ) : Path < ( String , Version ) > ,
184- conn : DbConnection ,
181+ mut conn : DbConnection ,
185182 Extension ( build_queue) : Extension < Arc < BuildQueue > > ,
186183 Extension ( config) : Extension < Arc < Config > > ,
187184 opt_auth_header : Option < TypedHeader < Authorization < Bearer > > > ,
@@ -204,7 +201,7 @@ pub(crate) async fn build_trigger_rebuild_handler(
204201 ) ) ) ;
205202 }
206203
207- build_trigger_check ( conn, & name, & version, & build_queue)
204+ build_trigger_check ( & mut * conn, & name, & version, & build_queue)
208205 . await
209206 . map_err ( JsonAxumNope ) ?;
210207
0 commit comments