aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/repository
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-02 17:43:26 +0900
committernsfisis <nsfisis@gmail.com>2026-08-02 17:43:38 +0900
commit97b5211ab3a41d63ea50d0ca1ecfde6ad3323525 (patch)
treed058292255adb87b2914aac31f6ea31a87b93140 /crates/shirabe/src/repository
parent48af92c807a7cd1df54c2b1df5dba508aefc6b6e (diff)
downloadphp-shirabe-97b5211ab3a41d63ea50d0ca1ecfde6ad3323525.tar.gz
php-shirabe-97b5211ab3a41d63ea50d0ca1ecfde6ad3323525.tar.zst
php-shirabe-97b5211ab3a41d63ea50d0ca1ecfde6ad3323525.zip
fix(repository): restore late-bound initialize in FilesystemRepository add/remove
ArrayRepository::addPackage()/removePackage() rely on PHP late binding to run FilesystemRepository::initialize (reading the file) on first touch. The inner delegation skipped that: an add on a not-yet-read repository froze the array to just the added packages (a later write() would truncate installed.json), and a remove hit the packages-initialized expect(). Guard both with ensure_initialized(), matching the pattern used by the read paths. Same defect class as the 3e367f78 downloader fix. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/repository')
-rw-r--r--crates/shirabe/src/repository/filesystem_repository.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/crates/shirabe/src/repository/filesystem_repository.rs b/crates/shirabe/src/repository/filesystem_repository.rs
index 9186a836..88317be2 100644
--- a/crates/shirabe/src/repository/filesystem_repository.rs
+++ b/crates/shirabe/src/repository/filesystem_repository.rs
@@ -179,10 +179,18 @@ impl FilesystemRepository {
}
pub fn add_package(&mut self, package: PackageInterfaceHandle) -> anyhow::Result<()> {
+ // PHP: ArrayRepository::addPackage() calls the late-bound $this->initialize(), which must
+ // resolve to FilesystemRepository::initialize (reading the file). Without this guard the
+ // inner ArrayRepository would self-initialize to an empty array and the file would never
+ // be read (and a later write() would truncate it to just the added packages).
+ self.ensure_initialized()?;
self.inner.add_package(package)
}
pub fn remove_package(&mut self, package: PackageInterfaceHandle) -> anyhow::Result<()> {
+ // PHP: ArrayRepository::removePackage() iterates the late-bound $this->getPackages(),
+ // which initializes through FilesystemRepository::initialize first.
+ self.ensure_initialized()?;
self.inner.remove_package(package)
}