diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-25 16:44:29 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-26 00:20:05 +0900 |
| commit | f5f429dbae0a3e2d8224c0b1e4edcef54805d286 (patch) | |
| tree | 9f837baeeae6efa0ed926b181b8c273128d86c49 /crates/shirabe/src/util/http_downloader.rs | |
| parent | 3a0d9340810a8808d963135a884f50d08442ac67 (diff) | |
| download | php-shirabe-f5f429dbae0a3e2d8224c0b1e4edcef54805d286.tar.gz php-shirabe-f5f429dbae0a3e2d8224c0b1e4edcef54805d286.tar.zst php-shirabe-f5f429dbae0a3e2d8224c0b1e4edcef54805d286.zip | |
feat(http): reimplement CurlDownloader on reqwest; port 15 more tests
Replace the libcurl-shim CurlDownloader with a reqwest+tokio implementation per
the .ken sketch, resolving the construction panic that blocked command tests
(mock path via __new_mock is untouched). Port remote_filesystem (7), hg/svn
driver (4), zip_archiver/git_exclude_filter (4) tests. Fix hg/svn/git_exclude
regex-delimiter and svn result-propagation porting bugs.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/util/http_downloader.rs')
| -rw-r--r-- | crates/shirabe/src/util/http_downloader.rs | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/crates/shirabe/src/util/http_downloader.rs b/crates/shirabe/src/util/http_downloader.rs index 782f04a..9057899 100644 --- a/crates/shirabe/src/util/http_downloader.rs +++ b/crates/shirabe/src/util/http_downloader.rs @@ -557,20 +557,19 @@ impl HttpDownloader { } // curl branch: register the request with the curl multi handle. Completion is delivered - // asynchronously by curl.tick() into the job's `settled` slot (read by count_active_jobs). - // PHP catches any exception from download() and rejects the job. + // by curl.tick() into the job's `settled` slot (read by count_active_jobs). The resolve + // callback stores the Response, reject stores the error; this mirrors PHP's promise + // resolve/reject firing during tick(). PHP catches any exception from download() and + // rejects the job. let settled = self.jobs.get(&id).unwrap().settled.clone(); let settled_for_reject = settled.clone(); - let resolve: Box<dyn Fn(PhpMixed) + Send + Sync> = Box::new(move |_response: PhpMixed| { - // TODO(phase-c-promise): curl.tick() delivers the response as PhpMixed here; convert it - // into a Response and store Ok(..) in `settled`. Bottoms at the todo!() curl I/O. - let _ = &settled; - }); - let reject: Box<dyn Fn(PhpMixed) + Send + Sync> = Box::new(move |_error: PhpMixed| { - // TODO(phase-c-promise): convert the PhpMixed error into anyhow::Error and store - // Err(..) in `settled`. Bottoms at the todo!() curl I/O. - let _ = &settled_for_reject; + let resolve: Box<dyn Fn(Response) + Send + Sync> = Box::new(move |response: Response| { + *settled.lock().unwrap() = Some(Ok(response)); }); + let reject: Box<dyn Fn(anyhow::Error) + Send + Sync> = + Box::new(move |error: anyhow::Error| { + *settled_for_reject.lock().unwrap() = Some(Err(error)); + }); let download_result = { let curl = self.curl.as_mut().unwrap(); |
