diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-05 01:22:46 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-05 01:22:46 +0900 |
| commit | adf14510b00929aaee85ccb8dedf9164878a0164 (patch) | |
| tree | c540e711155ee7bc65d2ac8b1a5ebdcbc33c7320 /crates/shirabe/src/downloader/xz_downloader.rs | |
| parent | c5bcf222f98d13b104231713bf4a0aa0833c420a (diff) | |
| download | php-shirabe-adf14510b00929aaee85ccb8dedf9164878a0164.tar.gz php-shirabe-adf14510b00929aaee85ccb8dedf9164878a0164.tar.zst php-shirabe-adf14510b00929aaee85ccb8dedf9164878a0164.zip | |
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 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/downloader/xz_downloader.rs')
| -rw-r--r-- | crates/shirabe/src/downloader/xz_downloader.rs | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/crates/shirabe/src/downloader/xz_downloader.rs b/crates/shirabe/src/downloader/xz_downloader.rs index 10a7edf..1c03f1d 100644 --- a/crates/shirabe/src/downloader/xz_downloader.rs +++ b/crates/shirabe/src/downloader/xz_downloader.rs @@ -44,10 +44,28 @@ impl XzDownloader { cleanup_executed: IndexMap::new(), } } +} + +impl ArchiveDownloader for XzDownloader { + fn inner(&self) -> &FileDownloader { + &self.inner + } + + fn inner_mut(&mut self) -> &mut FileDownloader { + &mut self.inner + } + + fn cleanup_executed(&self) -> &IndexMap<String, bool> { + &self.cleanup_executed + } - pub(crate) async fn extract( + fn cleanup_executed_mut(&mut self) -> &mut IndexMap<String, bool> { + &mut self.cleanup_executed + } + + async fn extract( &mut self, - package: PackageInterfaceHandle, + _package: PackageInterfaceHandle, file: &str, path: &str, ) -> Result<Option<PhpMixed>> { @@ -119,9 +137,7 @@ impl crate::downloader::DownloaderInterface for XzDownloader { path: &str, prev_package: Option<PackageInterfaceHandle>, ) -> Result<Option<PhpMixed>> { - self.inner - .prepare(r#type, package, path, prev_package) - .await + <Self as ArchiveDownloader>::prepare(self, r#type, package, path, prev_package).await } async fn install( @@ -130,7 +146,7 @@ impl crate::downloader::DownloaderInterface for XzDownloader { path: &str, output: bool, ) -> Result<Option<PhpMixed>> { - self.inner.install(package, path, output).await + <Self as ArchiveDownloader>::install(self, package, path, output).await } async fn update( @@ -158,8 +174,6 @@ impl crate::downloader::DownloaderInterface for XzDownloader { path: &str, prev_package: Option<PackageInterfaceHandle>, ) -> Result<Option<PhpMixed>> { - self.inner - .cleanup(r#type, package, path, prev_package) - .await + <Self as ArchiveDownloader>::cleanup(self, r#type, package, path, prev_package).await } } |
