aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/mozart/src/commands
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-02-24 01:00:48 +0900
committernsfisis <nsfisis@gmail.com>2026-02-24 01:00:48 +0900
commit64ed53cf184fb05cbfe9f0336bc8695ff0e800f8 (patch)
treecea8c1854c5c7bf0fcffcaf175f1bf188d9f8904 /crates/mozart/src/commands
parentd9858fbd322ce20de84f44ce67ae11edf081578c (diff)
downloadphp-mozart-64ed53cf184fb05cbfe9f0336bc8695ff0e800f8.tar.gz
php-mozart-64ed53cf184fb05cbfe9f0336bc8695ff0e800f8.tar.zst
php-mozart-64ed53cf184fb05cbfe9f0336bc8695ff0e800f8.zip
fix(cache): enable dist archive caching for all commands
files_cache was Option<&Cache> and install_from_lock always passed None, so downloaded zip/tar archives were never cached. Make the parameter non-optional (&Cache) and wire it through every command that downloads dist archives (install, update, require, remove, create-project, archive). The Cache internally respects --no-cache via its enabled flag, so the Option wrapper was unnecessary. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'crates/mozart/src/commands')
-rw-r--r--crates/mozart/src/commands/archive.rs21
-rw-r--r--crates/mozart/src/commands/create_project.rs12
-rw-r--r--crates/mozart/src/commands/install.rs9
-rw-r--r--crates/mozart/src/commands/reinstall.rs2
-rw-r--r--crates/mozart/src/commands/remove.rs5
-rw-r--r--crates/mozart/src/commands/require.rs1
-rw-r--r--crates/mozart/src/commands/status.rs2
-rw-r--r--crates/mozart/src/commands/update.rs1
8 files changed, 42 insertions, 11 deletions
diff --git a/crates/mozart/src/commands/archive.rs b/crates/mozart/src/commands/archive.rs
index 2490246..faa0e94 100644
--- a/crates/mozart/src/commands/archive.rs
+++ b/crates/mozart/src/commands/archive.rs
@@ -96,6 +96,7 @@ pub async fn execute(
let cache_config = mozart_registry::cache::build_cache_config(cli.no_cache);
let repo_cache = mozart_registry::cache::Cache::repo(&cache_config);
+ let files_cache = mozart_registry::cache::Cache::files(&cache_config);
// 1. Determine working directory
let working_dir = match &cli.working_dir {
@@ -153,7 +154,14 @@ pub async fn execute(
let meta: PackageMeta = if let Some(ref pkg_name) = args.package {
// Remote package mode
console.info("Searching for the specified package.");
- resolve_remote_package(pkg_name, args.version.as_deref(), &repo_cache, console).await?
+ resolve_remote_package(
+ pkg_name,
+ args.version.as_deref(),
+ &repo_cache,
+ &files_cache,
+ console,
+ )
+ .await?
} else {
// Root package mode
if !composer_json_path.exists() {
@@ -248,6 +256,7 @@ async fn resolve_remote_package(
package_name: &str,
version_constraint: Option<&str>,
repo_cache: &mozart_registry::cache::Cache,
+ files_cache: &mozart_registry::cache::Cache,
console: &mozart_core::console::Console,
) -> anyhow::Result<PackageMeta> {
use mozart_core::package::Stability;
@@ -334,9 +343,13 @@ async fn resolve_remote_package(
let temp_dir = temp_base.join(&unique);
std::fs::create_dir_all(&temp_dir)?;
- let bytes =
- mozart_registry::downloader::download_dist(&dist.url, dist.shasum.as_deref(), None, None)
- .await?;
+ let bytes = mozart_registry::downloader::download_dist(
+ &dist.url,
+ dist.shasum.as_deref(),
+ None,
+ files_cache,
+ )
+ .await?;
match dist.dist_type.as_str() {
"zip" => mozart_registry::downloader::extract_zip(&bytes, &temp_dir)?,
diff --git a/crates/mozart/src/commands/create_project.rs b/crates/mozart/src/commands/create_project.rs
index 63d8a1a..a137868 100644
--- a/crates/mozart/src/commands/create_project.rs
+++ b/crates/mozart/src/commands/create_project.rs
@@ -274,6 +274,7 @@ pub async fn execute(
let cache_config = mozart_registry::cache::build_cache_config(cli.no_cache);
let repo_cache = mozart_registry::cache::Cache::repo(&cache_config);
+ let files_cache = mozart_registry::cache::Cache::files(&cache_config);
let versions = packagist::fetch_package_versions(&package_name, &repo_cache).await?;
@@ -326,9 +327,13 @@ pub async fn execute(
format!("{package_name} ({concrete_version})"),
);
- let bytes =
- downloader::download_dist(&dist.url, dist.shasum.as_deref(), Some(&mut progress), None)
- .await?;
+ let bytes = downloader::download_dist(
+ &dist.url,
+ dist.shasum.as_deref(),
+ Some(&mut progress),
+ &files_cache,
+ )
+ .await?;
progress.finish();
@@ -509,6 +514,7 @@ pub async fn execute(
apcu_autoloader_prefix: None,
download_only: false,
prefer_source: args.prefer_source,
+ no_cache: cli.no_cache,
},
console,
)
diff --git a/crates/mozart/src/commands/install.rs b/crates/mozart/src/commands/install.rs
index 6eedd05..477253c 100644
--- a/crates/mozart/src/commands/install.rs
+++ b/crates/mozart/src/commands/install.rs
@@ -119,6 +119,8 @@ pub struct InstallConfig {
pub download_only: bool,
/// Prefer installing from VCS source rather than dist archives.
pub prefer_source: bool,
+ /// Disable the files cache entirely.
+ pub no_cache: bool,
}
impl Default for InstallConfig {
@@ -136,6 +138,7 @@ impl Default for InstallConfig {
apcu_autoloader_prefix: None,
download_only: false,
prefer_source: false,
+ no_cache: false,
}
}
}
@@ -356,6 +359,9 @@ pub async fn install_from_lock(
config: &InstallConfig,
console: &mozart_core::console::Console,
) -> anyhow::Result<()> {
+ let cache_config = mozart_registry::cache::build_cache_config(config.no_cache);
+ let files_cache = mozart_registry::cache::Cache::files(&cache_config);
+
let dev_mode = config.dev_mode;
// Step 1: Determine which packages to install
@@ -492,7 +498,7 @@ pub async fn install_from_lock(
vendor_dir,
&pkg.name,
Some(&mut progress),
- None,
+ &files_cache,
)
.await?;
@@ -697,6 +703,7 @@ pub async fn execute(
apcu_autoloader_prefix: args.apcu_autoloader_prefix.clone(),
download_only: args.download_only,
prefer_source,
+ no_cache: cli.no_cache,
},
console,
)
diff --git a/crates/mozart/src/commands/reinstall.rs b/crates/mozart/src/commands/reinstall.rs
index abc207f..875d5f0 100644
--- a/crates/mozart/src/commands/reinstall.rs
+++ b/crates/mozart/src/commands/reinstall.rs
@@ -239,7 +239,7 @@ pub async fn execute(
&vendor_dir,
&locked.name,
Some(&mut progress),
- Some(&files_cache),
+ &files_cache,
)
.await?;
diff --git a/crates/mozart/src/commands/remove.rs b/crates/mozart/src/commands/remove.rs
index d489466..7afa51d 100644
--- a/crates/mozart/src/commands/remove.rs
+++ b/crates/mozart/src/commands/remove.rs
@@ -135,7 +135,7 @@ pub async fn execute(
// When --unused is set with no explicit packages, we re-resolve to detect
// packages in the lock file that are no longer reachable from root requirements.
if args.unused && args.packages.is_empty() {
- return remove_unused(&raw, &working_dir, args, &repo_cache, console).await;
+ return remove_unused(&raw, &working_dir, args, &repo_cache, cli.no_cache, console).await;
}
// Step 5: Determine which packages to remove and remove them
@@ -444,6 +444,7 @@ pub async fn execute(
apcu_autoloader_prefix: args.apcu_autoloader_prefix.clone(),
download_only: false,
prefer_source: false,
+ no_cache: cli.no_cache,
},
console,
)
@@ -459,6 +460,7 @@ async fn remove_unused(
working_dir: &std::path::Path,
args: &RemoveArgs,
repo_cache: &mozart_registry::cache::Cache,
+ no_cache: bool,
console: &mozart_core::console::Console,
) -> anyhow::Result<()> {
let lock_path = working_dir.join("composer.lock");
@@ -587,6 +589,7 @@ async fn remove_unused(
apcu_autoloader_prefix: args.apcu_autoloader_prefix.clone(),
download_only: false,
prefer_source: false,
+ no_cache,
},
console,
)
diff --git a/crates/mozart/src/commands/require.rs b/crates/mozart/src/commands/require.rs
index 5f02f5f..016a536 100644
--- a/crates/mozart/src/commands/require.rs
+++ b/crates/mozart/src/commands/require.rs
@@ -864,6 +864,7 @@ pub async fn execute(
apcu_autoloader_prefix: args.apcu_autoloader_prefix.clone(),
download_only: false,
prefer_source: args.prefer_source,
+ no_cache: cli.no_cache,
},
console,
)
diff --git a/crates/mozart/src/commands/status.rs b/crates/mozart/src/commands/status.rs
index 7cefe96..6d8fc98 100644
--- a/crates/mozart/src/commands/status.rs
+++ b/crates/mozart/src/commands/status.rs
@@ -116,7 +116,7 @@ pub async fn execute(
&dist.url,
dist.shasum.as_deref(),
None,
- Some(&files_cache),
+ &files_cache,
)
.await;
diff --git a/crates/mozart/src/commands/update.rs b/crates/mozart/src/commands/update.rs
index 9f47794..da2fd95 100644
--- a/crates/mozart/src/commands/update.rs
+++ b/crates/mozart/src/commands/update.rs
@@ -1221,6 +1221,7 @@ pub async fn execute(
apcu_autoloader_prefix: args.apcu_autoloader_prefix.clone(),
download_only: false,
prefer_source,
+ no_cache: cli.no_cache,
},
console,
)