@@ -26,7 +26,7 @@ use tracing::{debug, info, instrument};
2626/// NOTE: `source_files` refers to the files originally in the crate,
2727/// not the files generated by rustdoc.
2828#[ allow( clippy:: too_many_arguments) ]
29- #[ instrument( skip( conn) ) ]
29+ #[ instrument( skip( conn, compression_algorithms ) ) ]
3030pub ( crate ) async fn add_package_into_database (
3131 conn : & mut sqlx:: PgConnection ,
3232 metadata_pkg : & MetadataPackage ,
@@ -37,9 +37,10 @@ pub(crate) async fn add_package_into_database(
3737 registry_data : & ReleaseData ,
3838 has_docs : bool ,
3939 has_examples : bool ,
40- compression_algorithms : std :: collections :: HashSet < CompressionAlgorithm > ,
40+ compression_algorithms : impl IntoIterator < Item = CompressionAlgorithm > ,
4141 repository_id : Option < i32 > ,
4242 archive_storage : bool ,
43+ source_size : u64 ,
4344) -> Result < i32 > {
4445 debug ! ( "Adding package into database" ) ;
4546 let crate_id = initialize_crate ( conn, & metadata_pkg. name ) . await ?;
@@ -58,12 +59,12 @@ pub(crate) async fn add_package_into_database(
5859 keywords, have_examples, downloads, files,
5960 doc_targets, is_library,
6061 documentation_url, default_target, features,
61- repository_id, archive_storage
62+ repository_id, archive_storage, source_size
6263 )
6364 VALUES (
6465 $1, $2, $3, $4, $5, $6, $7, $8, $9,
6566 $10, $11, $12, $13, $14, $15, $16, $17, $18,
66- $19, $20, $21, $22, $23, $24, $25
67+ $19, $20, $21, $22, $23, $24, $25, $26
6768 )
6869 ON CONFLICT (crate_id, version) DO UPDATE
6970 SET release_time = $3,
@@ -88,7 +89,8 @@ pub(crate) async fn add_package_into_database(
8889 default_target = $22,
8990 features = $23,
9091 repository_id = $24,
91- archive_storage = $25
92+ archive_storage = $25,
93+ source_size = $26
9294 RETURNING id" ,
9395 crate_id,
9496 & metadata_pkg. version,
@@ -114,7 +116,8 @@ pub(crate) async fn add_package_into_database(
114116 default_target,
115117 features as Vec <Feature >,
116118 repository_id,
117- archive_storage
119+ archive_storage,
120+ source_size as i64 ,
118121 )
119122 . fetch_one ( & mut * conn)
120123 . await ?;
@@ -239,6 +242,7 @@ pub(crate) async fn finish_build(
239242 rustc_version : & str ,
240243 docsrs_version : & str ,
241244 build_status : BuildStatus ,
245+ documentation_size : Option < u64 > ,
242246 errors : Option < & str > ,
243247) -> Result < ( ) > {
244248 debug ! ( "updating build after finishing" ) ;
@@ -252,15 +256,17 @@ pub(crate) async fn finish_build(
252256 build_status = $3,
253257 build_server = $4,
254258 errors = $5,
259+ documentation_size = $6,
255260 build_time = NOW()
256261 WHERE
257- id = $6
262+ id = $7
258263 RETURNING rid" ,
259264 rustc_version,
260265 docsrs_version,
261266 build_status as BuildStatus ,
262267 hostname. to_str( ) . unwrap_or( "" ) ,
263268 errors,
269+ documentation_size. map( |v| v as i64 ) ,
264270 build_id,
265271 )
266272 . fetch_one ( & mut * conn)
@@ -654,6 +660,7 @@ mod test {
654660 "rustc_version" ,
655661 "docsrs_version" ,
656662 BuildStatus :: Success ,
663+ Some ( 42 ) ,
657664 None ,
658665 )
659666 . await ?;
@@ -663,6 +670,7 @@ mod test {
663670 rustc_version,
664671 docsrs_version,
665672 build_status as "build_status: BuildStatus",
673+ documentation_size,
666674 errors
667675 FROM builds
668676 WHERE id = $1"# ,
@@ -674,6 +682,7 @@ mod test {
674682 assert_eq ! ( row. rustc_version, Some ( "rustc_version" . into( ) ) ) ;
675683 assert_eq ! ( row. docsrs_version, Some ( "docsrs_version" . into( ) ) ) ;
676684 assert_eq ! ( row. build_status, BuildStatus :: Success ) ;
685+ assert_eq ! ( row. documentation_size, Some ( 42 ) ) ;
677686 assert ! ( row. errors. is_none( ) ) ;
678687
679688 Ok ( ( ) )
@@ -694,6 +703,7 @@ mod test {
694703 "rustc_version" ,
695704 "docsrs_version" ,
696705 BuildStatus :: Failure ,
706+ None ,
697707 Some ( "error message" ) ,
698708 )
699709 . await ?;
@@ -703,6 +713,7 @@ mod test {
703713 rustc_version,
704714 docsrs_version,
705715 build_status as "build_status: BuildStatus",
716+ documentation_size,
706717 errors
707718 FROM builds
708719 WHERE id = $1"# ,
@@ -715,6 +726,7 @@ mod test {
715726 assert_eq ! ( row. docsrs_version, Some ( "docsrs_version" . into( ) ) ) ;
716727 assert_eq ! ( row. build_status, BuildStatus :: Failure ) ;
717728 assert_eq ! ( row. errors, Some ( "error message" . into( ) ) ) ;
729+ assert ! ( row. documentation_size. is_none( ) ) ;
718730
719731 Ok ( ( ) )
720732 } )
0 commit comments