🎨 校验索引发现文件系统相关问题并修复后自动刷新界面

This commit is contained in:
Liang Ding 2023-02-14 09:27:20 +08:00
parent fe63530325
commit 675318dbbc
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
6 changed files with 21 additions and 5 deletions

View file

@ -113,6 +113,7 @@ func resetDuplicateBlocksOnFileSys() {
boxes := Conf.GetBoxes()
luteEngine := lute.New()
blockIDs := map[string]bool{}
needRefreshUI := false
for _, box := range boxes {
boxPath := filepath.Join(util.DataDir, box.ID)
filepath.Walk(boxPath, func(path string, info os.FileInfo, err error) error {
@ -158,6 +159,7 @@ func resetDuplicateBlocksOnFileSys() {
// 如果是文档根节点,则直接重置这颗树
logging.LogWarnf("exist more than one tree with the same id [%s], reset it", box.ID+p)
recreateTree(tree, path)
needRefreshUI = true
return ast.WalkStop
}
@ -165,6 +167,7 @@ func resetDuplicateBlocksOnFileSys() {
needOverwrite = true
n.ID = ast.NewNodeID()
n.SetIALAttr("id", n.ID)
needRefreshUI = true
return ast.WalkContinue
})
@ -177,6 +180,14 @@ func resetDuplicateBlocksOnFileSys() {
return nil
})
}
if needRefreshUI {
util.ReloadUI()
go func() {
time.Sleep(time.Second * 3)
util.PushMsg(Conf.Language(190), 5000)
}()
}
}
func recreateTree(tree *parse.Tree, absPath string) {