diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-08-02 08:42:55 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-08-02 08:42:55 +0900 |
| commit | b5d6d91054b9ceef95aef0819bb5c4ef7db1abdd (patch) | |
| tree | 0bd12e599f48fcc63375363363416ca48766c698 /crates/shirabe/src/repository/writable_array_repository.rs | |
| parent | 3e367f78eec3521106979461fda717926717515a (diff) | |
| download | php-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/repository/writable_array_repository.rs')
| -rw-r--r-- | crates/shirabe/src/repository/writable_array_repository.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/crates/shirabe/src/repository/writable_array_repository.rs b/crates/shirabe/src/repository/writable_array_repository.rs index e415a1e1..f5db2bd9 100644 --- a/crates/shirabe/src/repository/writable_array_repository.rs +++ b/crates/shirabe/src/repository/writable_array_repository.rs @@ -31,6 +31,11 @@ impl WritableArrayRepository { self.dev_mode } + /// See `ArrayRepository::base_count`; kept on `&self` for `is_fresh` callers. + pub(crate) fn base_count(&self) -> usize { + self.inner.base_count() + } + pub fn set_dev_package_names(&mut self, dev_package_names: Vec<String>) { self.dev_package_names = dev_package_names; } @@ -124,11 +129,11 @@ impl WritableArrayRepository { } impl RepositoryInterface for WritableArrayRepository { - fn count(&self) -> anyhow::Result<usize> { + fn count(&mut self) -> anyhow::Result<usize> { self.inner.count() } - fn has_package(&self, package: PackageInterfaceHandle) -> bool { + fn has_package(&mut self, package: PackageInterfaceHandle) -> anyhow::Result<bool> { self.inner.has_package(package) } |
