@@ -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,34 @@ 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 COUNT(*) as "count!"
133
+ FROM releases
134
+ INNER JOIN crates ON crates.id = releases.crate_id
135
+ WHERE crates.name = $1 AND releases.version = $2"# ,
136
+ name,
137
+ version. to_string( ) ,
138
+ )
139
+ . fetch_one ( & mut * conn)
140
+ . await ?;
141
+ Ok ( row. count > 0 )
142
+ }
143
+
144
+ async fn build_trigger_check (
145
+ conn : DbConnection ,
146
+ name : & String ,
147
+ version : & Version ,
130
148
build_queue : & Arc < BuildQueue > ,
131
149
) -> AxumResult < impl IntoResponse > {
132
- let _ = CrateDetails :: new ( & mut * conn, & name, & version, None , vec ! [ ] )
133
- . await ?
134
- . ok_or ( AxumNope :: VersionNotFound ) ? ;
150
+ if ! crate_version_exists ( conn, name, version) . await ? {
151
+ return Err ( AxumNope :: VersionNotFound ) ;
152
+ }
135
153
136
154
let crate_version_is_in_queue = spawn_blocking ( {
137
155
let name = name. clone ( ) ;
0 commit comments