@@ -581,7 +581,32 @@ impl RustwideBuilder {
581581 None
582582 } ;
583583
584- let has_examples = build. host_source_dir ( ) . join ( "examples" ) . is_dir ( ) ;
584+ let mut async_conn = self . runtime . block_on ( self . db . get_async ( ) ) ?;
585+
586+ self . runtime . block_on ( finish_build (
587+ & mut async_conn,
588+ build_id,
589+ & res. result . rustc_version ,
590+ & res. result . docsrs_version ,
591+ if res. result . successful {
592+ BuildStatus :: Success
593+ } else {
594+ BuildStatus :: Failure
595+ } ,
596+ documentation_size,
597+ None ,
598+ ) ) ?;
599+
600+ {
601+ let _span = info_span ! ( "store_build_logs" ) . entered ( ) ;
602+ let build_log_path = format ! ( "build-logs/{build_id}/{default_target}.txt" ) ;
603+ self . storage . store_one ( build_log_path, res. build_log ) ?;
604+ for ( target, log) in target_build_logs {
605+ let build_log_path = format ! ( "build-logs/{build_id}/{target}.txt" ) ;
606+ self . storage . store_one ( build_log_path, log) ?;
607+ }
608+ }
609+
585610 if res. result . successful {
586611 self . metrics . successful_builds . inc ( ) ;
587612 } else if res. cargo_metadata . root ( ) . is_library ( ) {
@@ -611,8 +636,26 @@ impl RustwideBuilder {
611636 let cargo_metadata = res. cargo_metadata . root ( ) ;
612637 let repository = self . get_repo ( cargo_metadata) ?;
613638
614- let mut async_conn = self . runtime . block_on ( self . db . get_async ( ) ) ?;
639+ // when we have an unsuccessful build, but the release was already successfullly
640+ // built in the past, don't touch the release record so the docs stay intact.
641+ // This mainly happens with manually triggered or automated rebuilds.
642+ // The `release_build_status` table is already updated with the information from
643+ // the current build via `finish_build`.
644+ let current_release_build_status = self . runtime . block_on ( sqlx:: query_scalar!(
645+ r#"
646+ SELECT build_status AS "build_status: BuildStatus"
647+ FROM release_build_status
648+ WHERE rid = $1
649+ "# ,
650+ release_id. 0 ,
651+ ) . fetch_optional ( & mut * async_conn) ) ?;
652+
653+ if !res. result . successful && current_release_build_status == Some ( BuildStatus :: Success ) {
654+ info ! ( "build was unsuccessful, but the release was already successfully built in the past. Skipping release record update." ) ;
655+ return Ok ( false ) ;
656+ }
615657
658+ let has_examples = build. host_source_dir ( ) . join ( "examples" ) . is_dir ( ) ;
616659 self . runtime . block_on ( finish_release (
617660 & mut async_conn,
618661 crate_id,
@@ -639,31 +682,6 @@ impl RustwideBuilder {
639682 ) ) ?;
640683 }
641684
642- let build_status = if res. result . successful {
643- BuildStatus :: Success
644- } else {
645- BuildStatus :: Failure
646- } ;
647- self . runtime . block_on ( finish_build (
648- & mut async_conn,
649- build_id,
650- & res. result . rustc_version ,
651- & res. result . docsrs_version ,
652- build_status,
653- documentation_size,
654- None ,
655- ) ) ?;
656-
657- {
658- let _span = info_span ! ( "store_build_logs" ) . entered ( ) ;
659- let build_log_path = format ! ( "build-logs/{build_id}/{default_target}.txt" ) ;
660- self . storage . store_one ( build_log_path, res. build_log ) ?;
661- for ( target, log) in target_build_logs {
662- let build_log_path = format ! ( "build-logs/{build_id}/{target}.txt" ) ;
663- self . storage . store_one ( build_log_path, log) ?;
664- }
665- }
666-
667685 // Some crates.io crate data is mutable, so we proactively update it during a release
668686 if !is_local {
669687 match self
0 commit comments