aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/repository
diff options
context:
space:
mode:
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)
}