@@ -133,7 +133,7 @@ pub(crate) async fn build_list_json_handler(
133133}
134134
135135async fn crate_version_exists (
136- mut conn : DbConnection ,
136+ conn : & mut sqlx :: PgConnection ,
137137 name : & String ,
138138 version : & Version ,
139139) -> Result < bool , anyhow:: Error > {
@@ -153,22 +153,19 @@ async fn crate_version_exists(
153153}
154154
155155async fn build_trigger_check (
156- conn : DbConnection ,
156+ conn : & mut sqlx :: PgConnection ,
157157 name : & String ,
158158 version : & Version ,
159159 build_queue : & Arc < BuildQueue > ,
160160) -> AxumResult < impl IntoResponse > {
161- if !crate_version_exists ( conn, name, version) . await ? {
161+ if !crate_version_exists ( & mut * conn, name, version) . await ? {
162162 return Err ( AxumNope :: VersionNotFound ) ;
163163 }
164164
165- let crate_version_is_in_queue = spawn_blocking ( {
166- let name = name. clone ( ) ;
167- let version_string = version. to_string ( ) ;
168- let build_queue = build_queue. clone ( ) ;
169- move || build_queue. has_build_queued ( & name, & version_string)
170- } )
171- . await ?;
165+ let crate_version_is_in_queue = build_queue
166+ . has_build_queued ( & mut * conn, & name, & version. to_string ( ) )
167+ . await ?;
168+
172169 if crate_version_is_in_queue {
173170 return Err ( AxumNope :: BadRequest ( anyhow ! (
174171 "crate {name} {version} already queued for rebuild"
@@ -184,7 +181,7 @@ const TRIGGERED_REBUILD_PRIORITY: i32 = 5;
184181
185182pub ( crate ) async fn build_trigger_rebuild_handler (
186183 Path ( ( name, version) ) : Path < ( String , Version ) > ,
187- conn : DbConnection ,
184+ mut conn : DbConnection ,
188185 Extension ( build_queue) : Extension < Arc < BuildQueue > > ,
189186 Extension ( config) : Extension < Arc < Config > > ,
190187 opt_auth_header : Option < TypedHeader < Authorization < Bearer > > > ,
@@ -207,7 +204,7 @@ pub(crate) async fn build_trigger_rebuild_handler(
207204 ) ) ) ;
208205 }
209206
210- build_trigger_check ( conn, & name, & version, & build_queue)
207+ build_trigger_check ( & mut * conn, & name, & version, & build_queue)
211208 . await
212209 . map_err ( JsonAxumNope ) ?;
213210
0 commit comments