Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion crates/lib/docs_rs_storage/src/archive_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,20 @@ impl Cache {

// fast path: try to use whatever is there, no locking
let force_redownload = match find_in_file(&local_index_path, path_in_archive).await {
Ok(res) => return Ok(res),
Ok(res) => {
// Keep moka's recency/frequency view in sync with successful fast-path
// file lookups so TTI and admission decisions reflect real usage.
if self.manager.get(&local_index_path).await.is_none() {
let entry_path = local_index_path.clone();
self.manager
.entry(local_index_path.clone())
.or_insert_with(
async move { Arc::new(Entry::from_path(&entry_path).await) },
)
.await;
}
return Ok(res);
}
Err(err) => {
let force_redownload = !err.is::<PathNotFoundError>();
debug!(?err, "archive index lookup failed, will try repair.");
Expand Down Expand Up @@ -1107,6 +1120,7 @@ mod tests {
downloader.download_count(&format!("{ARCHIVE_NAME}.{ARCHIVE_INDEX_FILE_EXTENSION}")),
0
);
assert!(cache.manager.get(&cache_file).await.is_some());

Ok(())
}
Expand Down
Loading