aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/tests/downloader/file_downloader_test.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-07-18 18:03:57 +0900
committernsfisis <nsfisis@gmail.com>2026-07-18 18:03:57 +0900
commit9b291d454b059977639db26c847af4e835cda0c3 (patch)
treee54770570a80e67681f1614841156b864452713c /crates/shirabe/tests/downloader/file_downloader_test.rs
parentf8e385f7a1bd752d39f4d4f87b0439596839dde9 (diff)
downloadphp-shirabe-9b291d454b059977639db26c847af4e835cda0c3.tar.gz
php-shirabe-9b291d454b059977639db26c847af4e835cda0c3.tar.zst
php-shirabe-9b291d454b059977639db26c847af4e835cda0c3.zip
refactor(downloader): take &self across the downloader hierarchy
Concurrent package operations call into the same downloader instances through Rc<RefCell<dyn DownloaderInterface>>; with &mut self methods every call holds a RefMut across its awaits, which panics with 'already mutably borrowed' the moment two operations overlap. This is groundwork for fanning out InstallationManager's download/install loops (same rework HttpDownloader/CurlDownloader already got). - DownloaderInterface/ChangeReportInterface/ArchiveDownloader/ VcsDownloader methods now take &self; as_change_report_interface returns &dyn instead of &mut dyn. - Implementors move their genuinely mutable state behind cells: FileDownloader.additional_cleanup_paths, the archive downloaders' cleanup_executed, ZipDownloader.zip_archive_object, VcsDownloaderBase.has_cleaned_changes, GitDownloader's stash/discard/ cache maps and GitUtil, SvnDownloader.cache_credentials, PerforceDownloader.perforce. FileDownloader.io gains a RefCell layer so get_local_changes can keep PHP's NullIO swap under &self. - ProcessExecutor::execute_async now returns a future that captures everything up front instead of borrowing the executor, and call sites build the future before awaiting, so no borrow on the shared executor is held while a subprocess runs. - Filesystem::remove_directory_async becomes remove_directory_async_via taking the Rc handle: the Filesystem is only borrowed for the sync head/tail, never across the rm subprocess await (sync borrow_mut users like rename/ensure_directory_exists would otherwise collide). - DownloadManager async call sites hold shared borrows only. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/tests/downloader/file_downloader_test.rs')
-rw-r--r--crates/shirabe/tests/downloader/file_downloader_test.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/crates/shirabe/tests/downloader/file_downloader_test.rs b/crates/shirabe/tests/downloader/file_downloader_test.rs
index a9af69ed..451b792e 100644
--- a/crates/shirabe/tests/downloader/file_downloader_test.rs
+++ b/crates/shirabe/tests/downloader/file_downloader_test.rs
@@ -79,7 +79,7 @@ fn get_downloader(
fn test_download_for_package_without_dist_reference() {
let package = get_package("dummy/pkg", "1.0.0");
- let (mut downloader, _http_downloader, _guard) = get_downloader(None, None);
+ let (downloader, _http_downloader, _guard) = get_downloader(None, None);
let result = run(downloader.download(package, "/path", None, true));
let e = result.expect_err("expected InvalidArgumentException");
@@ -101,7 +101,7 @@ fn test_download_to_existing_file() {
std::fs::write(&path, b"").unwrap();
let path = path.to_string_lossy().into_owned();
- let (mut downloader, _http_downloader, _guard) = get_downloader(None, None);
+ let (downloader, _http_downloader, _guard) = get_downloader(None, None);
let result = run(downloader.download(package, &path, None, true));
@@ -154,7 +154,7 @@ fn test_download_but_file_is_unsaved() {
);
let config = get_config(config_options);
- let (mut downloader, http_downloader, _guard) = get_downloader(None, Some(config));
+ let (downloader, http_downloader, _guard) = get_downloader(None, Some(config));
let mut loop_ = Loop::new(http_downloader, None);
let promise = Box::pin(async {
@@ -272,7 +272,7 @@ fn test_download_file_with_invalid_checksum() {
// The PHP test injects a Filesystem mock so cleanup is a no-op; a real Filesystem behaves the
// same here since nothing under the temp dir needs preserving.
- let (mut downloader, http_downloader, _guard) = get_downloader(None, Some(config));
+ let (downloader, http_downloader, _guard) = get_downloader(None, Some(config));
// make sure the file expected to be downloaded is on disk already
let dl_file = downloader.__get_file_name(package.clone(), &path);
@@ -350,7 +350,7 @@ fn test_downgrade_shows_appropriate_message() {
);
let io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>> = io_mock.clone();
- let mut downloader = FileDownloader::new(
+ let downloader = FileDownloader::new(
io,
config,
http_downloader.clone(),