Skip to content

Commit

Permalink
Delete existing message index when loading from snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
fridrik01 committed Mar 24, 2023
1 parent 48c57d3 commit e757030
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion chain/index/msgindex.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e757030

Please sign in to comment.