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