diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-02-24 00:23:30 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-02-24 00:23:30 +0900 |
| commit | af0df92e1ecc82823a510646b7545278caeac4b8 (patch) | |
| tree | 4b735eed50dd369895600c2f7cfd0039d274b2af /crates/mozart-registry/src/resolver.rs | |
| parent | 2622fa3089d1df249276083d157e43b080a59100 (diff) | |
| download | php-mozart-af0df92e1ecc82823a510646b7545278caeac4b8.tar.gz php-mozart-af0df92e1ecc82823a510646b7545278caeac4b8.tar.zst php-mozart-af0df92e1ecc82823a510646b7545278caeac4b8.zip | |
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 <noreply@anthropic.com>
Diffstat (limited to 'crates/mozart-registry/src/resolver.rs')
| -rw-r--r-- | crates/mozart-registry/src/resolver.rs | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/crates/mozart-registry/src/resolver.rs b/crates/mozart-registry/src/resolver.rs index 1cd5bb6..fe59824 100644 --- a/crates/mozart-registry/src/resolver.rs +++ b/crates/mozart-registry/src/resolver.rs @@ -344,8 +344,8 @@ pub struct ResolveRequest { pub ignore_platform_reqs: bool, /// Specific platform requirements to ignore. pub ignore_platform_req_list: Vec<String>, - /// Optional on-disk repo cache for Packagist API responses. - pub repo_cache: Option<Cache>, + /// On-disk repo cache for Packagist API responses. + pub repo_cache: Cache, /// Temporary version constraint overrides (from --with flag). /// Maps package name (lowercase) to constraint string. pub temporary_constraints: HashMap<String, String>, @@ -475,7 +475,7 @@ pub async fn resolve(request: &ResolveRequest) -> Result<Vec<ResolvedPackage>, R } // Fetch available versions from Packagist - let versions = packagist::fetch_package_versions(name, request.repo_cache.as_ref()) + let versions = packagist::fetch_package_versions(name, &request.repo_cache) .await .map_err(|e| { ResolveError::DependencyFetchError(format!("Failed to fetch {}: {}", name, e)) @@ -506,16 +506,15 @@ pub async fn resolve(request: &ResolveRequest) -> Result<Vec<ResolvedPackage>, R continue; } - let versions = - match packagist::fetch_package_versions(&name, request.repo_cache.as_ref()).await { - Ok(v) => v, - Err(_) => { - // Virtual/meta packages (e.g. "psr/http-client-implementation") - // don't exist on Packagist. They are resolved via provides/replaces - // from other packages already in the pool. - continue; - } - }; + let versions = match packagist::fetch_package_versions(&name, &request.repo_cache).await { + Ok(v) => v, + Err(_) => { + // Virtual/meta packages (e.g. "psr/http-client-implementation") + // don't exist on Packagist. They are resolved via provides/replaces + // from other packages already in the pool. + continue; + } + }; for pv in &versions { let inputs = packagist_to_pool_inputs( @@ -965,7 +964,7 @@ mod tests { platform: PlatformConfig::new(), ignore_platform_reqs: false, ignore_platform_req_list: vec![], - repo_cache: None, + repo_cache: Cache::new(std::env::temp_dir().join("mozart-test-cache"), false), temporary_constraints: HashMap::new(), repositories: vec![], }; |
