@@ -9,7 +9,6 @@ use crate::{
99 impl_axum_webpage,
1010 utils:: spawn_blocking,
1111 web:: {
12- crate_details:: CrateDetails ,
1312 error:: AxumResult ,
1413 extractors:: { DbConnection , Path } ,
1514 match_version, MetaData , ReqVersion ,
@@ -124,15 +123,35 @@ pub(crate) async fn build_list_json_handler(
124123 . into_response ( ) )
125124}
126125
127- async fn build_trigger_check (
126+ async fn crate_version_exists (
128127 mut conn : DbConnection ,
129128 name : & String ,
130129 version : & Version ,
130+ ) -> Result < bool , anyhow:: Error > {
131+ let row = sqlx:: query!(
132+ r#"
133+ SELECT 1 as "dummy"
134+ FROM releases
135+ INNER JOIN crates ON crates.id = releases.crate_id
136+ WHERE crates.name = $1 AND releases.version = $2
137+ LIMIT 1"# ,
138+ name,
139+ version. to_string( ) ,
140+ )
141+ . fetch_optional ( & mut * conn)
142+ . await ?;
143+ Ok ( row. is_some ( ) )
144+ }
145+
146+ async fn build_trigger_check (
147+ conn : DbConnection ,
148+ name : & String ,
149+ version : & Version ,
131150 build_queue : & Arc < BuildQueue > ,
132151) -> AxumResult < impl IntoResponse > {
133- let _ = CrateDetails :: new ( & mut * conn, & name, & version, None , vec ! [ ] )
134- . await ?
135- . ok_or ( AxumNope :: VersionNotFound ) ? ;
152+ if ! crate_version_exists ( conn, name, version) . await ? {
153+ return Err ( AxumNope :: VersionNotFound ) ;
154+ }
136155
137156 let crate_version_is_in_queue = spawn_blocking ( {
138157 let name = name. clone ( ) ;
0 commit comments