@@ -26,7 +26,7 @@ use tracing::{debug, info, instrument};
26
26
/// NOTE: `source_files` refers to the files originally in the crate,
27
27
/// not the files generated by rustdoc.
28
28
#[ allow( clippy:: too_many_arguments) ]
29
- #[ instrument( skip( conn) ) ]
29
+ #[ instrument( skip( conn, compression_algorithms ) ) ]
30
30
pub ( crate ) async fn add_package_into_database (
31
31
conn : & mut sqlx:: PgConnection ,
32
32
metadata_pkg : & MetadataPackage ,
@@ -37,9 +37,10 @@ pub(crate) async fn add_package_into_database(
37
37
registry_data : & ReleaseData ,
38
38
has_docs : bool ,
39
39
has_examples : bool ,
40
- compression_algorithms : std :: collections :: HashSet < CompressionAlgorithm > ,
40
+ compression_algorithms : impl IntoIterator < Item = CompressionAlgorithm > ,
41
41
repository_id : Option < i32 > ,
42
42
archive_storage : bool ,
43
+ source_size : u64 ,
43
44
) -> Result < i32 > {
44
45
debug ! ( "Adding package into database" ) ;
45
46
let crate_id = initialize_crate ( conn, & metadata_pkg. name ) . await ?;
@@ -58,12 +59,12 @@ pub(crate) async fn add_package_into_database(
58
59
keywords, have_examples, downloads, files,
59
60
doc_targets, is_library,
60
61
documentation_url, default_target, features,
61
- repository_id, archive_storage
62
+ repository_id, archive_storage, source_size
62
63
)
63
64
VALUES (
64
65
$1, $2, $3, $4, $5, $6, $7, $8, $9,
65
66
$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
67
68
)
68
69
ON CONFLICT (crate_id, version) DO UPDATE
69
70
SET release_time = $3,
@@ -88,7 +89,8 @@ pub(crate) async fn add_package_into_database(
88
89
default_target = $22,
89
90
features = $23,
90
91
repository_id = $24,
91
- archive_storage = $25
92
+ archive_storage = $25,
93
+ source_size = $26
92
94
RETURNING id" ,
93
95
crate_id,
94
96
& metadata_pkg. version,
@@ -114,7 +116,8 @@ pub(crate) async fn add_package_into_database(
114
116
default_target,
115
117
features as Vec <Feature >,
116
118
repository_id,
117
- archive_storage
119
+ archive_storage,
120
+ source_size as i64 ,
118
121
)
119
122
. fetch_one ( & mut * conn)
120
123
. await ?;
@@ -239,6 +242,7 @@ pub(crate) async fn finish_build(
239
242
rustc_version : & str ,
240
243
docsrs_version : & str ,
241
244
build_status : BuildStatus ,
245
+ documentation_size : Option < u64 > ,
242
246
errors : Option < & str > ,
243
247
) -> Result < ( ) > {
244
248
debug ! ( "updating build after finishing" ) ;
@@ -252,15 +256,17 @@ pub(crate) async fn finish_build(
252
256
build_status = $3,
253
257
build_server = $4,
254
258
errors = $5,
259
+ documentation_size = $6,
255
260
build_time = NOW()
256
261
WHERE
257
- id = $6
262
+ id = $7
258
263
RETURNING rid" ,
259
264
rustc_version,
260
265
docsrs_version,
261
266
build_status as BuildStatus ,
262
267
hostname. to_str( ) . unwrap_or( "" ) ,
263
268
errors,
269
+ documentation_size. map( |v| v as i64 ) ,
264
270
build_id,
265
271
)
266
272
. fetch_one ( & mut * conn)
@@ -654,6 +660,7 @@ mod test {
654
660
"rustc_version" ,
655
661
"docsrs_version" ,
656
662
BuildStatus :: Success ,
663
+ Some ( 42 ) ,
657
664
None ,
658
665
)
659
666
. await ?;
@@ -663,6 +670,7 @@ mod test {
663
670
rustc_version,
664
671
docsrs_version,
665
672
build_status as "build_status: BuildStatus",
673
+ documentation_size,
666
674
errors
667
675
FROM builds
668
676
WHERE id = $1"# ,
@@ -674,6 +682,7 @@ mod test {
674
682
assert_eq ! ( row. rustc_version, Some ( "rustc_version" . into( ) ) ) ;
675
683
assert_eq ! ( row. docsrs_version, Some ( "docsrs_version" . into( ) ) ) ;
676
684
assert_eq ! ( row. build_status, BuildStatus :: Success ) ;
685
+ assert_eq ! ( row. documentation_size, Some ( 42 ) ) ;
677
686
assert ! ( row. errors. is_none( ) ) ;
678
687
679
688
Ok ( ( ) )
@@ -694,6 +703,7 @@ mod test {
694
703
"rustc_version" ,
695
704
"docsrs_version" ,
696
705
BuildStatus :: Failure ,
706
+ None ,
697
707
Some ( "error message" ) ,
698
708
)
699
709
. await ?;
@@ -703,6 +713,7 @@ mod test {
703
713
rustc_version,
704
714
docsrs_version,
705
715
build_status as "build_status: BuildStatus",
716
+ documentation_size,
706
717
errors
707
718
FROM builds
708
719
WHERE id = $1"# ,
@@ -715,6 +726,7 @@ mod test {
715
726
assert_eq ! ( row. docsrs_version, Some ( "docsrs_version" . into( ) ) ) ;
716
727
assert_eq ! ( row. build_status, BuildStatus :: Failure ) ;
717
728
assert_eq ! ( row. errors, Some ( "error message" . into( ) ) ) ;
729
+ assert ! ( row. documentation_size. is_none( ) ) ;
718
730
719
731
Ok ( ( ) )
720
732
} )
0 commit comments