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(
830830    Path ( params) :  Path < JsonDownloadParams > , 
831831    mut  conn :  DbConnection , 
832832    Extension ( config) :  Extension < Arc < Config > > , 
833+     Extension ( storage) :  Extension < Arc < AsyncStorage > > , 
833834)  -> AxumResult < impl  IntoResponse >  { 
834835    let  matched_release = match_version ( & mut  conn,  & params. name ,  & params. version ) 
835836        . await ?
@@ -875,6 +876,10 @@ pub(crate) async fn json_download_handler(
875876        format_version, 
876877    ) ; 
877878
879+     if  !storage. exists ( & storage_path) . await ? { 
880+         return  Err ( AxumNope :: ResourceNotFound ) ; 
881+     } 
882+ 
878883    // since we didn't build rustdoc json for all releases yet, 
879884    // this redirect might redirect to a location that doesn't exist. 
880885    Ok ( super :: axum_cached_redirect ( 
@@ -3166,6 +3171,7 @@ mod test {
31663171
31673172    #[ test_case( "0.1.0/json" ;  "rustdoc status false" ) ]  
31683173    #[ test_case( "0.2.0/unknown-target/json" ;  "unknown target" ) ]  
3174+     #[ test_case( "0.2.0/json/99" ;  "target file doesnt exist" ) ]  
31693175    #[ test_case( "0.42.0/json" ;  "unknown version" ) ]  
31703176    fn  json_download_not_found ( request_path_suffix :  & str )  { 
31713177        async_wrapper ( |env| async  move  { 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments