File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -830,6 +830,7 @@ pub(crate) async fn json_download_handler(
830
830
Path ( params) : Path < JsonDownloadParams > ,
831
831
mut conn : DbConnection ,
832
832
Extension ( config) : Extension < Arc < Config > > ,
833
+ Extension ( storage) : Extension < Arc < AsyncStorage > > ,
833
834
) -> AxumResult < impl IntoResponse > {
834
835
let matched_release = match_version ( & mut conn, & params. name , & params. version )
835
836
. await ?
@@ -875,6 +876,10 @@ pub(crate) async fn json_download_handler(
875
876
format_version,
876
877
) ;
877
878
879
+ if !storage. exists ( & storage_path) . await ? {
880
+ return Err ( AxumNope :: ResourceNotFound ) ;
881
+ }
882
+
878
883
// since we didn't build rustdoc json for all releases yet,
879
884
// this redirect might redirect to a location that doesn't exist.
880
885
Ok ( super :: axum_cached_redirect (
@@ -3166,6 +3171,7 @@ mod test {
3166
3171
3167
3172
#[ test_case( "0.1.0/json" ; "rustdoc status false" ) ]
3168
3173
#[ test_case( "0.2.0/unknown-target/json" ; "unknown target" ) ]
3174
+ #[ test_case( "0.2.0/json/99" ; "target file doesnt exist" ) ]
3169
3175
#[ test_case( "0.42.0/json" ; "unknown version" ) ]
3170
3176
fn json_download_not_found ( request_path_suffix : & str ) {
3171
3177
async_wrapper ( |env| async move {
You can’t perform that action at this time.
0 commit comments