diff options
Diffstat (limited to 'crates/shirabe/src/downloader')
| -rw-r--r-- | crates/shirabe/src/downloader/download_manager.rs | 11 | ||||
| -rw-r--r-- | crates/shirabe/src/downloader/file_downloader.rs | 25 | ||||
| -rw-r--r-- | crates/shirabe/src/downloader/perforce_downloader.rs | 14 |
3 files changed, 30 insertions, 20 deletions
diff --git a/crates/shirabe/src/downloader/download_manager.rs b/crates/shirabe/src/downloader/download_manager.rs index a5a83a6..b978368 100644 --- a/crates/shirabe/src/downloader/download_manager.rs +++ b/crates/shirabe/src/downloader/download_manager.rs @@ -532,6 +532,17 @@ impl DownloadManager { Ok(sources) } + /// For testing only: exposes the private `getAvailableSources` for the + /// DownloadManagerTest::testGetAvailableSourcesUpdateSticksToSameSource case, + /// which reaches it through `ReflectionMethod` in PHP. + pub fn __get_available_sources( + &self, + package: PackageInterfaceHandle, + prev_package: Option<PackageInterfaceHandle>, + ) -> Result<Vec<String>> { + self.get_available_sources(package, prev_package) + } + /// Downloaders expect a /path/to/dir without trailing slash /// /// If any Installer provides a path with a trailing slash, this can cause bugs so make sure we remove them diff --git a/crates/shirabe/src/downloader/file_downloader.rs b/crates/shirabe/src/downloader/file_downloader.rs index b03db38..66f3390 100644 --- a/crates/shirabe/src/downloader/file_downloader.rs +++ b/crates/shirabe/src/downloader/file_downloader.rs @@ -124,18 +124,19 @@ impl FileDownloader { { // PHP: writeError('Running cache garbage collection', true, io_interface::VERY_VERBOSE) this.io.write_error("Running cache garbage collection"); - cache.borrow_mut().gc( - this.config - .borrow_mut() - .get("cache-files-ttl") - .as_int() - .unwrap_or(0), - this.config - .borrow_mut() - .get("cache-files-maxsize") - .as_int() - .unwrap_or(0), - ); + let ttl = this + .config + .borrow_mut() + .get("cache-files-ttl") + .as_int() + .unwrap_or(0); + let max_size = this + .config + .borrow_mut() + .get("cache-files-maxsize") + .as_int() + .unwrap_or(0); + cache.borrow_mut().gc(ttl, max_size); } this diff --git a/crates/shirabe/src/downloader/perforce_downloader.rs b/crates/shirabe/src/downloader/perforce_downloader.rs index f93cfa8..56d6957 100644 --- a/crates/shirabe/src/downloader/perforce_downloader.rs +++ b/crates/shirabe/src/downloader/perforce_downloader.rs @@ -12,6 +12,7 @@ use crate::package::PackageInterfaceHandle; use crate::repository::VcsRepository; use crate::util::Filesystem; use crate::util::Perforce; +use crate::util::PerforceInterface; use crate::util::ProcessExecutor; use anyhow::Result; use indexmap::IndexMap; @@ -20,7 +21,7 @@ use shirabe_php_shim::PhpMixed; #[derive(Debug)] pub struct PerforceDownloader { inner: VcsDownloaderBase, - pub(crate) perforce: Option<Perforce>, + pub(crate) perforce: Option<Box<dyn PerforceInterface>>, } impl PerforceDownloader { @@ -61,20 +62,20 @@ impl PerforceDownloader { } else { None }; - self.perforce = Some(Perforce::create( + self.perforce = Some(Box::new(Perforce::create( repo_config.unwrap_or_default(), url, path, self.inner.process.clone(), self.inner.io.clone(), - )); + ))); } fn get_repo_config(&self, repository: &VcsRepository) -> IndexMap<String, PhpMixed> { repository.get_repo_config().clone() } - pub fn set_perforce(&mut self, perforce: Perforce) { + pub fn set_perforce(&mut self, perforce: Box<dyn PerforceInterface>) { self.perforce = Some(perforce); } } @@ -135,10 +136,7 @@ impl VcsDownloader for PerforceDownloader { self.perforce.as_mut().unwrap().p4_login(); self.perforce.as_mut().unwrap().write_p4_client_spec(); self.perforce.as_mut().unwrap().connect_client(); - self.perforce - .as_mut() - .unwrap() - .sync_code_base(label.as_deref()); + self.perforce.as_mut().unwrap().sync_code_base(label); self.perforce.as_mut().unwrap().cleanup_client_spec(); Ok(None) |
