diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-02-22 11:07:42 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-02-22 11:15:29 +0900 |
| commit | 9f0d210021c54f63c9984446862b6ec68834bc63 (patch) | |
| tree | d1522b8047c60bc7ee7a9d832178dd24e1b07636 /crates/mozart/src/commands/archive.rs | |
| parent | 2c243a3cb814939bbe40fda1608781825ab0d77d (diff) | |
| download | php-mozart-9f0d210021c54f63c9984446862b6ec68834bc63.tar.gz php-mozart-9f0d210021c54f63c9984446862b6ec68834bc63.tar.zst php-mozart-9f0d210021c54f63c9984446862b6ec68834bc63.zip | |
refactor(async): migrate from blocking HTTP to async/await with tokio
Replace reqwest::blocking with async reqwest across the entire codebase.
All command execute functions, registry API calls (packagist, downloader,
resolver, lockfile), and the main entry point now use async/await with
the tokio runtime. The pubgrub resolver runs on spawn_blocking since its
DependencyProvider trait is synchronous, using Handle::block_on for
async I/O within that context.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'crates/mozart/src/commands/archive.rs')
| -rw-r--r-- | crates/mozart/src/commands/archive.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/crates/mozart/src/commands/archive.rs b/crates/mozart/src/commands/archive.rs index 687e116..08e6bcf 100644 --- a/crates/mozart/src/commands/archive.rs +++ b/crates/mozart/src/commands/archive.rs @@ -82,7 +82,7 @@ impl Drop for PackageMeta { // ─── Main entry point ───────────────────────────────────────────────────────── -pub fn execute( +pub async fn execute( args: &ArchiveArgs, cli: &super::Cli, console: &mozart_core::console::Console, @@ -148,7 +148,7 @@ pub fn execute( // 5. Determine source directory and package metadata let meta: PackageMeta = if let Some(ref pkg_name) = args.package { // Remote package mode - resolve_remote_package(pkg_name, args.version.as_deref())? + resolve_remote_package(pkg_name, args.version.as_deref()).await? } else { // Root package mode if !composer_json_path.exists() { @@ -239,7 +239,7 @@ pub fn execute( // ─── Remote package resolution ──────────────────────────────────────────────── -fn resolve_remote_package( +async fn resolve_remote_package( package_name: &str, version_constraint: Option<&str>, ) -> anyhow::Result<PackageMeta> { @@ -247,7 +247,7 @@ fn resolve_remote_package( use mozart_registry::version::find_best_candidate; // Fetch versions from Packagist - let versions = mozart_registry::packagist::fetch_package_versions(package_name, None)?; + let versions = mozart_registry::packagist::fetch_package_versions(package_name, None).await?; if versions.is_empty() { anyhow::bail!("No versions found for package \"{}\"", package_name); } @@ -293,7 +293,8 @@ fn resolve_remote_package( std::fs::create_dir_all(&temp_dir)?; let bytes = - mozart_registry::downloader::download_dist(&dist.url, dist.shasum.as_deref(), None, None)?; + mozart_registry::downloader::download_dist(&dist.url, dist.shasum.as_deref(), None, None) + .await?; match dist.dist_type.as_str() { "zip" => mozart_registry::downloader::extract_zip(&bytes, &temp_dir)?, |
