From adf14510b00929aaee85ccb8dedf9164878a0164 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Fri, 5 Jun 2026 01:22:46 +0900 Subject: feat(downloader): wire ArchiveDownloader extraction and Path/Zip overrides Implement ArchiveDownloader for Zip/Tar/Gzip/Xz/Phar/Rar so install() extracts the archive (extract + rename) instead of doing FileDownloader's plain file rename, and route install/prepare/cleanup through the mixin. ArchiveDownloader::extract becomes &mut self to match the concrete implementations. Route ZipDownloader's bespoke download() (unzip-command static init) and PathDownloader's symlink/junction/mirror download/install/remove through the DownloaderInterface trait (path: String -> &str). Co-Authored-By: Claude Opus 4.8 --- crates/shirabe/src/downloader/rar_downloader.rs | 30 ++++++++++++++++++------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'crates/shirabe/src/downloader/rar_downloader.rs') diff --git a/crates/shirabe/src/downloader/rar_downloader.rs b/crates/shirabe/src/downloader/rar_downloader.rs index 5676a96..f2c89c3 100644 --- a/crates/shirabe/src/downloader/rar_downloader.rs +++ b/crates/shirabe/src/downloader/rar_downloader.rs @@ -48,8 +48,26 @@ impl RarDownloader { cleanup_executed: IndexMap::new(), } } +} + +impl ArchiveDownloader for RarDownloader { + fn inner(&self) -> &FileDownloader { + &self.inner + } + + fn inner_mut(&mut self) -> &mut FileDownloader { + &mut self.inner + } + + fn cleanup_executed(&self) -> &IndexMap { + &self.cleanup_executed + } - pub(crate) async fn extract( + fn cleanup_executed_mut(&mut self) -> &mut IndexMap { + &mut self.cleanup_executed + } + + async fn extract( &mut self, _package: PackageInterfaceHandle, file: &str, @@ -185,9 +203,7 @@ impl crate::downloader::DownloaderInterface for RarDownloader { path: &str, prev_package: Option, ) -> Result> { - self.inner - .prepare(r#type, package, path, prev_package) - .await + ::prepare(self, r#type, package, path, prev_package).await } async fn install( @@ -196,7 +212,7 @@ impl crate::downloader::DownloaderInterface for RarDownloader { path: &str, output: bool, ) -> Result> { - self.inner.install(package, path, output).await + ::install(self, package, path, output).await } async fn update( @@ -224,8 +240,6 @@ impl crate::downloader::DownloaderInterface for RarDownloader { path: &str, prev_package: Option, ) -> Result> { - self.inner - .cleanup(r#type, package, path, prev_package) - .await + ::cleanup(self, r#type, package, path, prev_package).await } } -- cgit v1.3.1