From 23dc4e16da99870a2dae35c9021ea0057e6fc240 Mon Sep 17 00:00:00 2001 From: Tim Bruijnzeels Date: Sun, 1 Oct 2023 10:44:31 -0300 Subject: [PATCH] Fix KeyValueStore::is_empty for disk. --- src/commons/eventsourcing/kv.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/commons/eventsourcing/kv.rs b/src/commons/eventsourcing/kv.rs index d4a3f216..47c605e7 100644 --- a/src/commons/eventsourcing/kv.rs +++ b/src/commons/eventsourcing/kv.rs @@ -47,9 +47,12 @@ impl KeyValueStore { .map_err(KeyValueError::KVError) } - /// Returns true if this KeyValueStore (with this namespace) has any entries + /// Returns true if this KeyValueStore (with this namespace) has any entries. pub fn is_empty(&self) -> Result { - self.execute(&Scope::global(), |kv| kv.is_empty()) + // NOTE: this is done using `self.execute` as this would result in a lockfile + // to be created for disk based inner stores, and that would make them + // appear as not empty. + self.inner.is_empty().map_err(KeyValueError::KVError) } /// Wipe the complete store. Needless to say perhaps.. use with care..