@@ -47,6 +47,7 @@ use crate::config_json::{gen_config_json_file, is_config_json_url};
47
47
use crate :: crate_info:: CrateInfo ;
48
48
use crate :: file_cache:: {
49
49
cache_fetch_crate, cache_fetch_index_entry, cache_store_crate, cache_store_index_entry,
50
+ cache_try_find_index_entry,
50
51
} ;
51
52
use crate :: index_entry:: IndexEntry ;
52
53
use crate :: metadata_cache:: {
@@ -447,12 +448,12 @@ fn handle_index_request(request: Request, index_url: &str, config: &ProxyConfig)
447
448
for header in request. headers ( ) {
448
449
if header. field . equiv ( "If-None-Match" ) {
449
450
let etag = header. value . as_str ( ) ;
450
- debug ! ( "proxy: checking known index entry {index_entry} with ETag {etag}" ) ;
451
+ debug ! ( "proxy: checking known index entry {index_entry} with ETag: {etag}" ) ;
451
452
index_entry. set_etag ( etag) ;
452
453
}
453
454
if header. field . equiv ( "If-Modified-Since" ) {
454
455
let last_modified = header. value . as_str ( ) ;
455
- debug ! ( "proxy: checking known index entry {index_entry} with Last-Modified {last_modified}" ) ;
456
+ debug ! ( "proxy: checking known index entry {index_entry} with Last-Modified: {last_modified}" ) ;
456
457
index_entry. set_last_modified ( last_modified) ;
457
458
}
458
459
}
@@ -482,8 +483,19 @@ fn handle_index_request(request: Request, index_url: &str, config: &ProxyConfig)
482
483
}
483
484
}
484
485
486
+ // Try to recreate the index entry metadata from the cached file mtime.
487
+ let mtimed_entry = cache_try_find_index_entry ( & config. index_dir , index_entry. name ( ) ) ;
488
+
489
+ if let Some ( entry) = & mtimed_entry {
490
+ let last_modified = entry. last_modified ( ) . unwrap ( ) ;
491
+
492
+ info ! (
493
+ "proxy: recreated index cache metadata for {entry} with Last-Modified: {last_modified}"
494
+ ) ;
495
+ }
496
+
485
497
// Fall back to forwarding the request to the upstream registry.
486
- forward_index_request ( request, index_entry, None , config. clone ( ) ) ;
498
+ forward_index_request ( request, index_entry, mtimed_entry , config. clone ( ) ) ;
487
499
}
488
500
489
501
/// Processes one HTTP GET request.
0 commit comments