File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ pub struct CrateDetails {
38
38
release_time : DateTime < Utc > ,
39
39
build_status : bool ,
40
40
last_successful_build : Option < String > ,
41
- rustdoc_status : bool ,
41
+ pub rustdoc_status : bool ,
42
42
pub archive_storage : bool ,
43
43
repository_url : Option < String > ,
44
44
homepage_url : Option < String > ,
Original file line number Diff line number Diff line change @@ -473,6 +473,15 @@ pub(crate) async fn rustdoc_html_server_handler(
473
473
. await ?
474
474
. ok_or ( AxumNope :: ResourceNotFound ) ?;
475
475
476
+ if !krate. rustdoc_status {
477
+ rendering_time. step ( "redirect to crate" ) ;
478
+ return Ok ( axum_cached_redirect (
479
+ format ! ( "/crate/{}/{}" , params. name, version_or_latest) ,
480
+ CachePolicy :: ForeverInCdn ,
481
+ ) ?
482
+ . into_response ( ) ) ;
483
+ }
484
+
476
485
// if visiting the full path to the default target, remove the target from the path
477
486
// expects a req_path that looks like `[/:target]/.*`
478
487
if req_path. first ( ) . copied ( ) == Some ( & krate. metadata . default_target ) {
@@ -2589,4 +2598,28 @@ mod test {
2589
2598
Ok ( ( ) )
2590
2599
} )
2591
2600
}
2601
+
2602
+ #[ test_case( "/something/1.2.3/some_path/" , "/crate/something/1.2.3" ) ]
2603
+ #[ test_case( "/something/latest/some_path/" , "/crate/something/latest" ) ]
2604
+ fn rustdoc_page_from_failed_build_redirects_to_crate ( path : & str , expected : & str ) {
2605
+ wrapper ( |env| {
2606
+ env. fake_release ( )
2607
+ . name ( "something" )
2608
+ . version ( "1.2.3" )
2609
+ . archive_storage ( true )
2610
+ . build_result_failed ( )
2611
+ . create ( ) ?;
2612
+ let web = env. frontend ( ) ;
2613
+
2614
+ assert_redirect_cached (
2615
+ path,
2616
+ expected,
2617
+ CachePolicy :: ForeverInCdn ,
2618
+ web,
2619
+ & env. config ( ) ,
2620
+ ) ?;
2621
+
2622
+ Ok ( ( ) )
2623
+ } )
2624
+ }
2592
2625
}
You can’t perform that action at this time.
0 commit comments