@@ -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 ,
@@ -124,15 +123,35 @@ pub(crate) async fn build_list_json_handler(
124
123
. into_response ( ) )
125
124
}
126
125
127
- async fn build_trigger_check (
126
+ async fn crate_version_exists (
128
127
mut conn : DbConnection ,
129
128
name : & String ,
130
129
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 ,
131
150
build_queue : & Arc < BuildQueue > ,
132
151
) -> 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
+ }
136
155
137
156
let crate_version_is_in_queue = spawn_blocking ( {
138
157
let name = name. clone ( ) ;
0 commit comments