From c6b10bd024894f857bf35a8f84c5e273be6f860d Mon Sep 17 00:00:00 2001 From: nsfisis Date: Fri, 17 Jul 2026 17:51:12 +0900 Subject: refactor(http-downloader): drop the job table for a &self Semaphore core MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces Job/Request/JobHandle/id_gen/running_jobs/max_jobs with a tokio::sync::Semaphore permit held for the duration of each request. get/add/copy/add_copy are now &self (add/add_copy are also genuinely async); a shared execute()/dispatch() core replaces add_job/run_rfs_job/start_job/settle_job, returning the Response directly instead of deferring to wait()/count_active_jobs()/ get_response() (all removed — confirmed zero callers, same for the now-unused STATUS_* constants). get()/copy() stay synchronous rather than becoming async wrappers around add()/add_copy(), bridging via the existing sync_executor instead of the curl_runtime() introduced for CurlDownloader: their callers (~35 files reaching HttpDownloader) are mostly plain sync fns with no async boundary anywhere in the call chain, and forcing that propagation now would pull forward the dedicated async-propagation task. curl-eligible requests still route through curl_runtime() inside dispatch(), same as before — nesting sync_executor::block_on (no real reactor) around curl_runtime().block_on() (a real, separate Runtime) is safe; it's only nesting curl_runtime() inside itself that would panic. CurlDownloader no longer needs Rc> wrapping despite the original design sketch: since item 2 made all of its methods &self, a plain Option field works fine under HttpDownloader's own &self methods. get/add/copy/add_copy becoming &self (rather than &mut self) requires no changes at any of their ~35 calling files: RefMut/Ref both deref to a type that can call &self methods just fine. Verified manually against real network I/O (sandbox disabled): `shirabe show -a` (get()'s sync_executor-bridged path) and `shirabe create-project` (add_copy()'s genuinely async path via file_downloader.rs) both complete correctly with no hang. --- crates/shirabe/tests/util/http_downloader_test.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/shirabe/tests/util/http_downloader_test.rs') diff --git a/crates/shirabe/tests/util/http_downloader_test.rs b/crates/shirabe/tests/util/http_downloader_test.rs index 2be5eb96..0839cf30 100644 --- a/crates/shirabe/tests/util/http_downloader_test.rs +++ b/crates/shirabe/tests/util/http_downloader_test.rs @@ -43,7 +43,7 @@ fn test_capture_authentication_params_from_url() { let io: std::rc::Rc> = io_mock.clone(); Platform::put_env("COMPOSER_DISABLE_NETWORK", "1"); - let mut fs = HttpDownloader::new(io, config, IndexMap::new(), false); + let fs = HttpDownloader::new(io, config, IndexMap::new(), false); Platform::clear_env("COMPOSER_DISABLE_NETWORK"); if let Err(e) = fs.get( -- cgit v1.3.1