mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 15:37:56 -05:00
db: clear blobs when using --clear-db or --force-clear-db (#13605)
* Call Close() as part of ClearDB * Add method to clear blob storage * Clear blob storage when clearing DB
This commit is contained in:
@@ -3,6 +3,7 @@ package kv
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
@@ -84,10 +85,12 @@ func (s *Store) view(fn func(*bolt.Tx) error) error {
|
||||
|
||||
// ClearDB removes any previously stored data at the configured data directory.
|
||||
func (s *Store) ClearDB() error {
|
||||
if err := s.Close(); err != nil {
|
||||
return fmt.Errorf("failed to close db: %w", err)
|
||||
}
|
||||
if _, err := os.Stat(s.databasePath); os.IsNotExist(err) {
|
||||
return nil
|
||||
}
|
||||
prometheus.Unregister(createBoltCollector(s.db))
|
||||
return os.Remove(filepath.Join(s.databasePath, ProtectionDbFileName))
|
||||
}
|
||||
|
||||
|
||||
@@ -18,9 +18,6 @@ func SetupDB(t testing.TB, pubkeys [][fieldparams.BLSPubkeyLength]byte) iface.Va
|
||||
t.Fatalf("Failed to instantiate DB: %v", err)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
if err := db.Close(); err != nil {
|
||||
t.Fatalf("Failed to close database: %v", err)
|
||||
}
|
||||
if err := db.ClearDB(); err != nil {
|
||||
t.Fatalf("Failed to clear database: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user