aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/installer/plugin_installer.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-05-23 03:07:15 +0900
committernsfisis <nsfisis@gmail.com>2026-05-23 15:48:00 +0900
commite068a9d644fde6659a88accd55b3f1d0d9d7cf46 (patch)
treebb719a70eb8c840957a94a5601df8961055ceb0f /crates/shirabe/src/installer/plugin_installer.rs
parent60eb89529c8af2e4477e0bb65ed9e0f2dc7d3dd7 (diff)
downloadphp-shirabe-e068a9d644fde6659a88accd55b3f1d0d9d7cf46.tar.gz
php-shirabe-e068a9d644fde6659a88accd55b3f1d0d9d7cf46.tar.zst
php-shirabe-e068a9d644fde6659a88accd55b3f1d0d9d7cf46.zip
refactor(promise): rewrite promise bodies to async/await
Mechanically convert promise-returning function bodies to async/await: resolve() returns the value directly, forwarding calls get .await, and simple .then chains become await sequences. Also collapse the installer double-Option (Result<Option<Option<PhpMixed>>> -> Result<Option<PhpMixed>>). Hard spots that depend on the Loop::wait / job-machine boundary (accept/reject orchestration, closures capturing &mut self, batch waits) are left intact and marked with TODO(phase-c-promise) for manual porting. The crate does not compile yet; traits still need #[async_trait]. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/installer/plugin_installer.rs')
-rw-r--r--crates/shirabe/src/installer/plugin_installer.rs48
1 files changed, 15 insertions, 33 deletions
diff --git a/crates/shirabe/src/installer/plugin_installer.rs b/crates/shirabe/src/installer/plugin_installer.rs
index fd1fc99..4f9918e 100644
--- a/crates/shirabe/src/installer/plugin_installer.rs
+++ b/crates/shirabe/src/installer/plugin_installer.rs
@@ -96,7 +96,7 @@ impl InstallerInterface for PluginInstaller {
let _ = plugin_optional;
}
- self.inner.prepare(r#type, package, prev_package)
+ self.inner.prepare(r#type, package, prev_package).await
}
async fn download(
@@ -116,7 +116,7 @@ impl InstallerInterface for PluginInstaller {
}.into());
}
- self.inner.download(package, prev_package)
+ self.inner.download(package, prev_package).await
}
async fn install(
@@ -124,22 +124,13 @@ impl InstallerInterface for PluginInstaller {
repo: &mut dyn InstalledRepositoryInterface,
package: &dyn PackageInterface,
) -> Result<Option<PhpMixed>> {
- let promise = self.inner.install(repo, package)?;
- let promise = match promise {
- Some(p) => p,
- None => shirabe_external_packages::react::promise::resolve(None),
- };
+ self.inner.install(repo, package).await?;
// TODO(plugin): register package in plugin manager after install, rollback on failure
- Ok(Some(promise.then(
- Some(Box::new(move |_v| -> Option<PhpMixed> {
- Platform::workaround_filesystem_issues();
- // self.get_plugin_manager().register_package(package, true)?;
- // On error: self.rollback_install(e, repo, package)?;
- None
- })),
- None,
- )))
+ Platform::workaround_filesystem_issues();
+ // self.get_plugin_manager().register_package(package, true)?;
+ // On error: self.rollback_install(e, repo, package)?;
+ Ok(None)
}
async fn update(
@@ -148,23 +139,14 @@ impl InstallerInterface for PluginInstaller {
initial: &dyn PackageInterface,
target: &dyn PackageInterface,
) -> Result<Option<PhpMixed>> {
- let promise = self.inner.update(repo, initial, target)?;
- let promise = match promise {
- Some(p) => p,
- None => shirabe_external_packages::react::promise::resolve(None),
- };
+ self.inner.update(repo, initial, target).await?;
// TODO(plugin): deactivate initial and register target in plugin manager after update, rollback on failure
- Ok(Some(promise.then(
- Some(Box::new(move |_v| -> Option<PhpMixed> {
- Platform::workaround_filesystem_issues();
- // self.get_plugin_manager().deactivate_package(initial);
- // self.get_plugin_manager().register_package(target, true)?;
- // On error: self.rollback_install(e, repo, target)?;
- None
- })),
- None,
- )))
+ Platform::workaround_filesystem_issues();
+ // self.get_plugin_manager().deactivate_package(initial);
+ // self.get_plugin_manager().register_package(target, true)?;
+ // On error: self.rollback_install(e, repo, target)?;
+ Ok(None)
}
async fn uninstall(
@@ -177,7 +159,7 @@ impl InstallerInterface for PluginInstaller {
.borrow_mut()
.uninstall_package(package);
- self.inner.uninstall(repo, package)
+ self.inner.uninstall(repo, package).await
}
async fn cleanup(
@@ -186,7 +168,7 @@ impl InstallerInterface for PluginInstaller {
package: &dyn PackageInterface,
prev_package: Option<&dyn PackageInterface>,
) -> Result<Option<PhpMixed>> {
- self.inner.cleanup(r#type, package, prev_package)
+ self.inner.cleanup(r#type, package, prev_package).await
}
fn get_install_path(&self, package: &dyn PackageInterface) -> Option<String> {