From decbe6c9e51a7ed45e0253bde75925182d418936 Mon Sep 17 00:00:00 2001 From: Matt Hicks Date: Thu, 14 Nov 2024 10:14:52 -0600 Subject: [PATCH] Fixed a bug in HaloDBStore.truncate not always clearing every value --- halodb/src/main/scala/lightdb/halodb/HaloDBStore.scala | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/halodb/src/main/scala/lightdb/halodb/HaloDBStore.scala b/halodb/src/main/scala/lightdb/halodb/HaloDBStore.scala index da8d8b9e..c074f688 100644 --- a/halodb/src/main/scala/lightdb/halodb/HaloDBStore.scala +++ b/halodb/src/main/scala/lightdb/halodb/HaloDBStore.scala @@ -96,8 +96,12 @@ class HaloDBStore[Doc <: Document[Doc], Model <: DocumentModel[Doc]](directory: override def truncate()(implicit transaction: Transaction[Doc]): Int = { val size = count - instance.newIterator().asScala.foreach(r => instance.delete(r.getKey)) - size + if (size == 0) { + 0 + } else { + instance.newIterator().asScala.foreach(r => instance.delete(r.getKey)) + size + truncate() + } } override def dispose(): Unit = {