From b8137f6b4dbd5239d78c5cfd5fcf0b8eba5ed62a Mon Sep 17 00:00:00 2001 From: Fridrik Asmundsson Date: Fri, 24 Mar 2023 16:44:26 +0000 Subject: [PATCH] Delete existing message index when loading from snapshot --- chain/index/msgindex.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/chain/index/msgindex.go b/chain/index/msgindex.go index 477738338..89c2bdc9f 100644 --- a/chain/index/msgindex.go +++ b/chain/index/msgindex.go @@ -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)