Skip to content

Commit

Permalink
Fixed a bug in HaloDBStore.truncate not always clearing every value
Browse files Browse the repository at this point in the history
  • Loading branch information
darkfrog26 committed Nov 14, 2024
1 parent 796b56e commit decbe6c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions halodb/src/main/scala/lightdb/halodb/HaloDBStore.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit decbe6c

Please sign in to comment.