@@ -446,13 +446,15 @@ impl RustwideBuilder {
446446 Err ( err) => warn ! ( "{:#?}" , err) ,
447447 }
448448
449- // delete eventually existing files from pre-archive storage.
450- // we're doing this in the end so eventual problems in the build
451- // won't lead to non-existing docs.
452- for prefix in & [ "rustdoc" , "sources" ] {
453- let prefix = format ! ( "{}/{}/{}/" , prefix, name, version) ;
454- log:: debug!( "cleaning old storage folder {}" , prefix) ;
455- self . storage . delete_prefix ( & prefix) ?;
449+ if res. result . successful {
450+ // delete eventually existing files from pre-archive storage.
451+ // we're doing this in the end so eventual problems in the build
452+ // won't lead to non-existing docs.
453+ for prefix in & [ "rustdoc" , "sources" ] {
454+ let prefix = format ! ( "{}/{}/{}/" , prefix, name, version) ;
455+ log:: debug!( "cleaning old storage folder {}" , prefix) ;
456+ self . storage . delete_prefix ( & prefix) ?;
457+ }
456458 }
457459
458460 Ok ( res. result . successful )
@@ -878,4 +880,59 @@ mod tests {
878880 Ok ( ( ) )
879881 } )
880882 }
883+
884+ #[ test]
885+ #[ ignore]
886+ fn test_build_binary_crate ( ) {
887+ wrapper ( |env| {
888+ // some binary crate
889+ let crate_ = "heater" ;
890+ let version = "0.2.3" ;
891+
892+ let storage = env. storage ( ) ;
893+ let old_rustdoc_file = format ! ( "rustdoc/{}/{}/some_doc_file" , crate_, version) ;
894+ let old_source_file = format ! ( "sources/{}/{}/some_source_file" , crate_, version) ;
895+ storage. store_one ( & old_rustdoc_file, Vec :: new ( ) ) ?;
896+ storage. store_one ( & old_source_file, Vec :: new ( ) ) ?;
897+
898+ let mut builder = RustwideBuilder :: init ( env) . unwrap ( ) ;
899+ assert ! ( !builder. build_package( crate_, version, PackageKind :: CratesIo ) ?) ;
900+
901+ // check release record in the db (default and other targets)
902+ let mut conn = env. db ( ) . conn ( ) ;
903+ let rows = conn
904+ . query (
905+ "SELECT
906+ r.rustdoc_status,
907+ r.is_library
908+ FROM
909+ crates as c
910+ INNER JOIN releases AS r ON c.id = r.crate_id
911+ LEFT OUTER JOIN doc_coverage AS cov ON r.id = cov.release_id
912+ WHERE
913+ c.name = $1 AND
914+ r.version = $2" ,
915+ & [ & crate_, & version] ,
916+ )
917+ . unwrap ( ) ;
918+ let row = rows. get ( 0 ) . unwrap ( ) ;
919+
920+ assert ! ( !row. get:: <_, bool >( "rustdoc_status" ) ) ;
921+ assert ! ( !row. get:: <_, bool >( "is_library" ) ) ;
922+
923+ // doc archive exists
924+ let doc_archive = rustdoc_archive_path ( crate_, version) ;
925+ assert ! ( !storage. exists( & doc_archive) ?) ;
926+
927+ // source archive exists
928+ let source_archive = source_archive_path ( crate_, version) ;
929+ assert ! ( storage. exists( & source_archive) ?) ;
930+
931+ // old rustdoc & source files still exist
932+ assert ! ( storage. exists( & old_rustdoc_file) ?) ;
933+ assert ! ( storage. exists( & old_source_file) ?) ;
934+
935+ Ok ( ( ) )
936+ } )
937+ }
881938}
0 commit comments