From 8871b923fa3df1935c263db155cb8bc3d59705cd Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 10 May 2026 23:58:26 +0900 Subject: refactor(downloader): turn DownloadManager into downloader registry MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reshape DownloadManager from a hard-coded VCS match into a registry of DownloaderInterface instances keyed by source type, mirroring Composer's DownloadManager — with prefer-source/dist preferences, an IO handle, and a files cache. ArchiveManager now resolves dist sources through a shared DownloadManager instead of calling download_dist directly, and Composer::require / try_load take an IO so it flows through the factory wiring. --- crates/mozart-core/src/repository/downloader.rs | 2 +- .../src/repository/installer_executor/filesystem.rs | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-) (limited to 'crates/mozart-core/src/repository') diff --git a/crates/mozart-core/src/repository/downloader.rs b/crates/mozart-core/src/repository/downloader.rs index 56b3652..f2e33a7 100644 --- a/crates/mozart-core/src/repository/downloader.rs +++ b/crates/mozart-core/src/repository/downloader.rs @@ -80,7 +80,7 @@ impl DownloadProgress { /// Downloaded bytes are cached by URL in `files_cache`; cache hits skip the network request /// entirely. #[tracing::instrument(skip(expected_shasum, progress, files_cache))] -pub async fn download_dist( +pub(crate) async fn download_dist( url: &str, expected_shasum: Option<&str>, progress: Option<&mut DownloadProgress>, diff --git a/crates/mozart-core/src/repository/installer_executor/filesystem.rs b/crates/mozart-core/src/repository/installer_executor/filesystem.rs index 2b34e02..05143a0 100644 --- a/crates/mozart-core/src/repository/installer_executor/filesystem.rs +++ b/crates/mozart-core/src/repository/installer_executor/filesystem.rs @@ -146,22 +146,18 @@ fn install_from_source( match source_type { "git" => { let process = crate::vcs::process::ProcessExecutor::new(); - let git_util = - crate::vcs::util::git::GitUtil::new(process, vendor_dir.join(".cache").join("git")); - let downloader = GitDownloader::new(git_util); + let downloader = GitDownloader::new(process, vendor_dir.join(".cache").join("git")); downloader.download(url, reference, &target)?; downloader.install(url, reference, &target)?; } "svn" => { let process = crate::vcs::process::ProcessExecutor::new(); - let svn_util = crate::vcs::util::svn::SvnUtil::new(process); - let downloader = SvnDownloader::new(svn_util); + let downloader = SvnDownloader::new(process); downloader.install(url, reference, &target)?; } "hg" => { let process = crate::vcs::process::ProcessExecutor::new(); - let hg_util = crate::vcs::util::hg::HgUtil::new(process); - let downloader = HgDownloader::new(hg_util); + let downloader = HgDownloader::new(process); downloader.install(url, reference, &target)?; } _ => { -- cgit v1.3.1