🎨 Improve init sync stability

This commit is contained in:
Daniel 2023-07-18 01:08:18 +08:00
parent 317ecdb618
commit 4e69f9596c
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 7 additions and 3 deletions

View file

@ -99,7 +99,7 @@ func InitDatabase(forceRebuild bool) (err error) {
} }
} }
if gulu.File.IsExist(util.BlockTreePath) { if gulu.File.IsExist(util.BlockTreePath) {
os.RemoveAll(util.BlockTreePath) treenode.InitBlockTree(true)
} }
initDBConnection() initDBConnection()

View file

@ -456,7 +456,11 @@ func SaveBlockTree(force bool) {
defer blockTreeLock.Unlock() defer blockTreeLock.Unlock()
start := time.Now() start := time.Now()
os.MkdirAll(util.BlockTreePath, 0755) if err := os.MkdirAll(util.BlockTreePath, 0755); nil != err {
logging.LogErrorf("create block tree dir [%s] failed: %s", util.BlockTreePath, err)
os.Exit(logging.ExitCodeFileSysErr)
return
}
size := uint64(0) size := uint64(0)
var count int var count int