Delete existing message index when loading from snapshot

This commit is contained in:
Fridrik Asmundsson
2023-03-29 22:15:57 +02:00
committed by Maciej Witowski
parent 28fc74c3f8
commit 42f1760bb8
+5 -1
View File
@@ -176,8 +176,12 @@ func PopulateAfterSnapshot(lctx context.Context, basePath string, cs ChainStore)
}
dbPath := path.Join(basePath, dbName)
// if a database already exists, we try to delete it and create a new one
if _, err := os.Stat(dbPath); err == nil {
return xerrors.Errorf("msgindex already exists at %s", dbPath)
if err = os.Remove(dbPath); err != nil {
return xerrors.Errorf("msgindex already exists at %s and can't be deleted", dbPath)
}
}
db, err := sql.Open("sqlite3", dbPath)