@@ -7,6 +7,7 @@ pub use self::compression::{compress, decompress, CompressionAlgorithm, Compress
7
7
use self :: database:: DatabaseBackend ;
8
8
use self :: s3:: S3Backend ;
9
9
use crate :: error:: Result ;
10
+ use crate :: web:: metrics:: RenderingTimesRecorder ;
10
11
use crate :: { db:: Pool , Config , Metrics } ;
11
12
use anyhow:: { anyhow, ensure} ;
12
13
use chrono:: { DateTime , Utc } ;
@@ -145,12 +146,14 @@ impl Storage {
145
146
version : & str ,
146
147
path : & str ,
147
148
archive_storage : bool ,
149
+ fetch_time : & mut RenderingTimesRecorder ,
148
150
) -> Result < Blob > {
149
151
Ok ( if archive_storage {
150
152
self . get_from_archive (
151
153
& rustdoc_archive_path ( name, version) ,
152
154
path,
153
155
self . max_file_size_for ( path) ,
156
+ Some ( fetch_time) ,
154
157
) ?
155
158
} else {
156
159
// Add rustdoc prefix, name and version to the path for accessing the file stored in the database
@@ -171,6 +174,7 @@ impl Storage {
171
174
& source_archive_path ( name, version) ,
172
175
path,
173
176
self . max_file_size_for ( path) ,
177
+ None ,
174
178
) ?
175
179
} else {
176
180
let remote_path = format ! ( "sources/{}/{}/{}" , name, version, path) ;
@@ -270,10 +274,17 @@ impl Storage {
270
274
archive_path : & str ,
271
275
path : & str ,
272
276
max_size : usize ,
277
+ mut fetch_time : Option < & mut RenderingTimesRecorder > ,
273
278
) -> Result < Blob > {
279
+ if let Some ( ref mut t) = fetch_time {
280
+ t. step ( "find path in index" ) ;
281
+ }
274
282
let index = self . get_index_for ( archive_path) ?;
275
283
let info = index. find_file ( path) ?;
276
284
285
+ if let Some ( t) = fetch_time {
286
+ t. step ( "range request" ) ;
287
+ }
277
288
let blob = self . get_range (
278
289
archive_path,
279
290
max_size,
@@ -790,12 +801,12 @@ mod backend_tests {
790
801
assert ! ( local_index_location. exists( ) ) ;
791
802
assert ! ( storage. exists_in_archive( "folder/test.zip" , "src/main.rs" ) ?) ;
792
803
793
- let file = storage. get_from_archive ( "folder/test.zip" , "Cargo.toml" , std:: usize:: MAX ) ?;
804
+ let file = storage. get_from_archive ( "folder/test.zip" , "Cargo.toml" , std:: usize:: MAX , None ) ?;
794
805
assert_eq ! ( file. content, b"data" ) ;
795
806
assert_eq ! ( file. mime, "text/toml" ) ;
796
807
assert_eq ! ( file. path, "folder/test.zip/Cargo.toml" ) ;
797
808
798
- let file = storage. get_from_archive ( "folder/test.zip" , "src/main.rs" , std:: usize:: MAX ) ?;
809
+ let file = storage. get_from_archive ( "folder/test.zip" , "src/main.rs" , std:: usize:: MAX , None ) ?;
799
810
assert_eq ! ( file. content, b"data" ) ;
800
811
assert_eq ! ( file. mime, "text/rust" ) ;
801
812
assert_eq ! ( file. path, "folder/test.zip/src/main.rs" ) ;
0 commit comments