From 7cdcbac3699b011b2d1822ffeb679fa5ca5fb5fd Mon Sep 17 00:00:00 2001
From: Leo-Besancon <lb@massa.net>
Date: Thu, 19 Dec 2024 11:40:10 +0100
Subject: [PATCH] Update hd_cache.rs

---
 massa-module-cache/src/hd_cache.rs | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/massa-module-cache/src/hd_cache.rs b/massa-module-cache/src/hd_cache.rs
index b4e70dfe75..299029db09 100644
--- a/massa-module-cache/src/hd_cache.rs
+++ b/massa-module-cache/src/hd_cache.rs
@@ -75,17 +75,15 @@ impl HDCache {
     pub fn reset(&mut self) {
         let path = self.db.as_ref().unwrap().path().to_path_buf();
 
-        // Close the existing database
-        self.db.take();
+        // Close the existing database by dropping it
+        let _ = self.db.take();
 
         // Destroy the database files
-        let opts = Options::default();
-        DB::destroy(&opts, &path).expect("Failed to destroy the database");
+        DB::destroy(&Options::default(), &path).expect("Failed to destroy the database");
         // Reopen the database
         let db = DB::open_default(&path).expect(OPEN_ERROR);
-        let entry_count = db.iterator(IteratorMode::Start).count();
         self.db = Some(db);
-        self.entry_count = entry_count;
+        self.entry_count = 0;
     }
 
     /// Insert a new module in the cache