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/downloader/hg_downloader.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'crates/mozart-core/src/downloader/hg_downloader.rs') diff --git a/crates/mozart-core/src/downloader/hg_downloader.rs b/crates/mozart-core/src/downloader/hg_downloader.rs index 9fb918e..dfe3546 100644 --- a/crates/mozart-core/src/downloader/hg_downloader.rs +++ b/crates/mozart-core/src/downloader/hg_downloader.rs @@ -1,16 +1,19 @@ +use crate::downloader::{DownloaderInterface, VcsDownloader}; +use crate::vcs::process::ProcessExecutor; +use crate::vcs::util::hg::HgUtil; use anyhow::Result; use std::path::Path; -use crate::{downloader::VcsDownloader, vcs::util::hg::HgUtil}; - /// Mercurial downloader using clone/pull/update. pub struct HgDownloader { hg_util: HgUtil, } impl HgDownloader { - pub fn new(hg_util: HgUtil) -> Self { - Self { hg_util } + pub fn new(process: ProcessExecutor) -> Self { + Self { + hg_util: HgUtil::new(process), + } } } @@ -82,3 +85,9 @@ impl VcsDownloader for HgDownloader { false } } + +impl DownloaderInterface for HgDownloader { + fn as_vcs_downloader(&self) -> Option<&dyn VcsDownloader> { + Some(self) + } +} -- cgit v1.3.1