aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/installer/metapackage_installer.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-02 08:42:55 +0900
committernsfisis <nsfisis@gmail.com>2026-08-02 08:42:55 +0900
commitb5d6d91054b9ceef95aef0819bb5c4ef7db1abdd (patch)
tree0bd12e599f48fcc63375363363416ca48766c698 /crates/shirabe/src/installer/metapackage_installer.rs
parent3e367f78eec3521106979461fda717926717515a (diff)
downloadphp-shirabe-b5d6d91054b9ceef95aef0819bb5c4ef7db1abdd.tar.gz
php-shirabe-b5d6d91054b9ceef95aef0819bb5c4ef7db1abdd.tar.zst
php-shirabe-b5d6d91054b9ceef95aef0819bb5c4ef7db1abdd.zip
fix(repository): run lazy initialization in count/has_package
PHP's ArrayRepository::count()/hasPackage() call $this->initialize(), which late-binds to the concrete repository class and lazily loads its packages. The Rust pass-throughs skipped that: they ran ArrayRepository's stub initialize instead, returning 0/false and marking the repository initialized with an empty package list, which made ensure_initialized() skip the real initialization forever after. Take &mut self in RepositoryInterface::count/has_package so the lazy repositories (Filesystem, Platform, Composer) can guard with their real initialize, and return Result from has_package since that initialization can fail (PHP propagates the exception). InstallerInterface::is_installed and InstallationManager::is_package_installed/mark_alias_installed propagate the same way, which also resolves the TODO(phase-d) markers on Package/Path/Artifact/Vcs repositories about initialization errors being swallowed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/installer/metapackage_installer.rs')
-rw-r--r--crates/shirabe/src/installer/metapackage_installer.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/crates/shirabe/src/installer/metapackage_installer.rs b/crates/shirabe/src/installer/metapackage_installer.rs
index cb6d13c3..26032a6d 100644
--- a/crates/shirabe/src/installer/metapackage_installer.rs
+++ b/crates/shirabe/src/installer/metapackage_installer.rs
@@ -30,9 +30,9 @@ impl InstallerInterface for MetapackageInstaller {
fn is_installed(
&self,
- repo: &dyn InstalledRepositoryInterface,
+ repo: &mut dyn InstalledRepositoryInterface,
package: PackageInterfaceHandle,
- ) -> bool {
+ ) -> anyhow::Result<bool> {
repo.has_package(package)
}
@@ -85,7 +85,7 @@ impl InstallerInterface for MetapackageInstaller {
initial: PackageInterfaceHandle,
target: PackageInterfaceHandle,
) -> anyhow::Result<Option<PhpMixed>> {
- if !repo.borrow().has_package(initial.clone()) {
+ if !repo.borrow_mut().has_package(initial.clone())? {
return Err(InvalidArgumentException {
message: format!("Package is not installed: {}", initial),
code: 0,
@@ -114,7 +114,7 @@ impl InstallerInterface for MetapackageInstaller {
repo: &std::cell::RefCell<&mut dyn InstalledRepositoryInterface>,
package: PackageInterfaceHandle,
) -> anyhow::Result<Option<PhpMixed>> {
- if !repo.borrow().has_package(package.clone()) {
+ if !repo.borrow_mut().has_package(package.clone())? {
return Err(InvalidArgumentException {
message: format!("Package is not installed: {}", package),
code: 0,