diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-05-27 00:49:33 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-05-27 00:54:09 +0900 |
| commit | cc5d73c05a0abca2eebcc8a6afa0b1543ee49850 (patch) | |
| tree | 091a0d01232d927f13f3ab22700701804980f231 /crates/shirabe/src/downloader/zip_downloader.rs | |
| parent | c5850d62beabef0a6bcc4cf6a179589c0ba8f405 (diff) | |
| download | php-shirabe-cc5d73c05a0abca2eebcc8a6afa0b1543ee49850.tar.gz php-shirabe-cc5d73c05a0abca2eebcc8a6afa0b1543ee49850.tar.zst php-shirabe-cc5d73c05a0abca2eebcc8a6afa0b1543ee49850.zip | |
refactor(package): pass package handles by value throughout
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/downloader/zip_downloader.rs')
| -rw-r--r-- | crates/shirabe/src/downloader/zip_downloader.rs | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/crates/shirabe/src/downloader/zip_downloader.rs b/crates/shirabe/src/downloader/zip_downloader.rs index 4c72b91..17eeae5 100644 --- a/crates/shirabe/src/downloader/zip_downloader.rs +++ b/crates/shirabe/src/downloader/zip_downloader.rs @@ -5,7 +5,7 @@ use crate::downloader::DownloaderInterface; use crate::downloader::FileDownloader; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; -use crate::package::PackageInterface; +use crate::package::PackageInterfaceHandle; use crate::util::IniHelper; use crate::util::Platform; use anyhow::Result; @@ -62,9 +62,9 @@ impl ZipDownloader { pub async fn download( &mut self, - package: &dyn PackageInterface, + package: PackageInterfaceHandle, path: &str, - prev_package: Option<&dyn PackageInterface>, + prev_package: Option<PackageInterfaceHandle>, output: bool, ) -> Result<Option<PhpMixed>> { { @@ -202,7 +202,7 @@ impl ZipDownloader { async fn extract_with_system_unzip( &mut self, - package: &dyn PackageInterface, + package: PackageInterfaceHandle, file: &str, path: &str, ) -> Result<Option<PhpMixed>> { @@ -282,7 +282,7 @@ impl ZipDownloader { match process_result { Ok(process) => { if !process.is_successful() { - if self.cleanup_executed.contains_key(package.get_name()) { + if self.cleanup_executed.contains_key(&package.get_name()) { return Err(RuntimeException { message: format!( "Failed to extract {} as the installation was aborted by another package operation.", @@ -337,7 +337,7 @@ impl ZipDownloader { is_last_chance: bool, file: &str, path: &str, - package: &dyn PackageInterface, + package: PackageInterfaceHandle, executable: &str, ) -> Result<Option<PhpMixed>> { if is_last_chance { @@ -390,17 +390,19 @@ impl ZipDownloader { substr(&file_get_contents(file).unwrap_or_default(), -100, None).as_bytes() ) )); - if strlen(package.get_dist_url().unwrap_or("")) > 0 { + if strlen(&package.get_dist_url().unwrap_or_default()) > 0 { self.inner.io.write_error(&format!( "Origin URL: {}", - self.inner - .process_url(package, package.get_dist_url().unwrap_or(""))? + self.inner.process_url( + package.clone(), + &package.get_dist_url().unwrap_or_default() + )? )); let headers = { let response_headers = crate::downloader::file_downloader::RESPONSE_HEADERS .lock() .unwrap(); - match response_headers.get(package.get_name()) { + match response_headers.get(&package.get_name()) { Some(list) => PhpMixed::List( list.iter() .map(|s| Box::new(PhpMixed::String(s.clone()))) @@ -422,7 +424,7 @@ impl ZipDownloader { async fn extract_with_zip_archive( &mut self, - package: &dyn PackageInterface, + package: PackageInterfaceHandle, file: &str, path: &str, ) -> Result<Option<PhpMixed>> { @@ -521,7 +523,7 @@ impl ZipDownloader { pub(crate) async fn extract( &mut self, - package: &dyn PackageInterface, + package: PackageInterfaceHandle, file: &str, path: &str, ) -> Result<Option<PhpMixed>> { @@ -562,9 +564,9 @@ impl crate::downloader::DownloaderInterface for ZipDownloader { async fn download( &self, - package: &dyn PackageInterface, + package: PackageInterfaceHandle, path: &str, - prev_package: Option<&dyn PackageInterface>, + prev_package: Option<PackageInterfaceHandle>, output: bool, ) -> Result<Option<PhpMixed>> { self.inner @@ -575,9 +577,9 @@ impl crate::downloader::DownloaderInterface for ZipDownloader { async fn prepare( &self, r#type: &str, - package: &dyn PackageInterface, + package: PackageInterfaceHandle, path: &str, - prev_package: Option<&dyn PackageInterface>, + prev_package: Option<PackageInterfaceHandle>, ) -> Result<Option<PhpMixed>> { self.inner .prepare(r#type, package, path, prev_package) @@ -586,7 +588,7 @@ impl crate::downloader::DownloaderInterface for ZipDownloader { async fn install( &self, - package: &dyn PackageInterface, + package: PackageInterfaceHandle, path: &str, output: bool, ) -> Result<Option<PhpMixed>> { @@ -595,8 +597,8 @@ impl crate::downloader::DownloaderInterface for ZipDownloader { async fn update( &self, - initial: &dyn PackageInterface, - target: &dyn PackageInterface, + initial: PackageInterfaceHandle, + target: PackageInterfaceHandle, path: &str, ) -> Result<Option<PhpMixed>> { self.inner.update(initial, target, path).await @@ -604,7 +606,7 @@ impl crate::downloader::DownloaderInterface for ZipDownloader { async fn remove( &self, - package: &dyn PackageInterface, + package: PackageInterfaceHandle, path: &str, output: bool, ) -> Result<Option<PhpMixed>> { @@ -614,9 +616,9 @@ impl crate::downloader::DownloaderInterface for ZipDownloader { async fn cleanup( &self, r#type: &str, - package: &dyn PackageInterface, + package: PackageInterfaceHandle, path: &str, - prev_package: Option<&dyn PackageInterface>, + prev_package: Option<PackageInterfaceHandle>, ) -> Result<Option<PhpMixed>> { self.inner .cleanup(r#type, package, path, prev_package) |
