From af0df92e1ecc82823a510646b7545278caeac4b8 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Tue, 24 Feb 2026 00:23:30 +0900 Subject: feat(cache): enable repo cache for all Packagist API calls Remove the Option wrapper from repo_cache in ResolveRequest, LockFileGenerationRequest, and fetch_package_versions. All commands now initialize a Cache via build_cache_config(cli.no_cache), ensuring Packagist metadata is cached to disk (respecting --no-cache flag). Co-Authored-By: Claude Opus 4.6 --- crates/mozart-registry/src/packagist.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'crates/mozart-registry/src/packagist.rs') diff --git a/crates/mozart-registry/src/packagist.rs b/crates/mozart-registry/src/packagist.rs index 8a5f205..64ff11a 100644 --- a/crates/mozart-registry/src/packagist.rs +++ b/crates/mozart-registry/src/packagist.rs @@ -212,21 +212,20 @@ pub fn parse_p2_response(json: &str, package_name: &str) -> anyhow::Result, + repo_cache: &Cache, ) -> anyhow::Result> { // Build cache key: replace `/` with `~` per cache key convention let cache_key = format!("provider-{}.json", package_name.replace('/', "~")); // Check cache first - if let Some(cache) = repo_cache - && let Some(cached) = cache.read(&cache_key) - { + if let Some(cached) = repo_cache.read(&cache_key) { tracing::debug!("cache hit"); return parse_p2_response(&cached, package_name); } @@ -250,9 +249,7 @@ pub async fn fetch_package_versions( let body = response.text().await?; // Write to cache - if let Some(cache) = repo_cache { - let _ = cache.write(&cache_key, &body); - } + let _ = repo_cache.write(&cache_key, &body); parse_p2_response(&body, package_name) } -- cgit v1.3.1