aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/downloader/zip_downloader.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-03 23:06:16 +0900
committernsfisis <nsfisis@gmail.com>2026-06-03 23:06:16 +0900
commit60bfd667e4a98f5463a5bd5f2d0259bd0eeb0a5e (patch)
treefd701c69882f6ce67da31fdc3ce0693e3141fddc /crates/shirabe/src/downloader/zip_downloader.rs
parenteba99f7e5f38d9501b37d9b188b6f324a947dc74 (diff)
downloadphp-shirabe-60bfd667e4a98f5463a5bd5f2d0259bd0eeb0a5e.tar.gz
php-shirabe-60bfd667e4a98f5463a5bd5f2d0259bd0eeb0a5e.tar.zst
php-shirabe-60bfd667e4a98f5463a5bd5f2d0259bd0eeb0a5e.zip
feat(downloader): wire as_* downcasts for file/archive/path/git downloaders
Override DownloaderInterface's as_change_report_interface / as_vcs_capable_downloader_interface / as_dvcs_downloader_interface so PHP-style instanceof checks resolve to the concrete sub-interface: FileDownloader and the six archive downloaders (Zip/Tar/Gzip/Xz/Rar/Phar) plus PathDownloader gain ChangeReportInterface (archives/path delegate to the inner FileDownloader), PathDownloader exposes VcsCapableDownloaderInterface, and GitDownloader exposes DvcsDownloaderInterface. The default None impls remain correct for downloaders that do not implement a given sub-interface, so their stale TODO markers are dropped. VCS downloaders' ChangeReport/VcsCapable conformance follows separately. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/downloader/zip_downloader.rs')
-rw-r--r--crates/shirabe/src/downloader/zip_downloader.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/crates/shirabe/src/downloader/zip_downloader.rs b/crates/shirabe/src/downloader/zip_downloader.rs
index 17eeae5..3fda248 100644
--- a/crates/shirabe/src/downloader/zip_downloader.rs
+++ b/crates/shirabe/src/downloader/zip_downloader.rs
@@ -1,6 +1,7 @@
//! ref: composer/src/Composer/Downloader/ZipDownloader.php
use crate::downloader::ArchiveDownloader;
+use crate::downloader::ChangeReportInterface;
use crate::downloader::DownloaderInterface;
use crate::downloader::FileDownloader;
use crate::io::IOInterface;
@@ -553,6 +554,16 @@ impl ZipDownloader {
}
}
+impl ChangeReportInterface for ZipDownloader {
+ fn get_local_changes(
+ &self,
+ package: PackageInterfaceHandle,
+ path: &str,
+ ) -> Result<Option<String>> {
+ self.inner.get_local_changes(package, path)
+ }
+}
+
// TODO(phase-b): ZipDownloader::download is overridden with extra setup (UNZIP_COMMANDS init,
// etc.). The trait method here delegates straight to the inner FileDownloader; the bespoke
// override on the struct itself takes &mut self and is not yet routed through the trait.
@@ -562,6 +573,10 @@ impl crate::downloader::DownloaderInterface for ZipDownloader {
self.inner.get_installation_source()
}
+ fn as_change_report_interface(&self) -> Option<&dyn crate::downloader::ChangeReportInterface> {
+ Some(self)
+ }
+
async fn download(
&self,
package: PackageInterfaceHandle,