Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2024-06-28 12:41:17 +08:00
commit ca5d6d4054
2 changed files with 24 additions and 4 deletions

View file

@ -1312,11 +1312,11 @@ func GetFullHPathByID(id string) (hPath string, err error) {
}
box := Conf.Box(tree.Box)
var boxName string
if nil != box {
boxName = box.Name
if nil == box {
err = ErrBoxNotFound
return
}
hPath = boxName + tree.HPath
hPath = box.Name + tree.HPath
return
}

View file

@ -1413,6 +1413,7 @@ func processSyncMergeResult(exit, byHand bool, mergeResult *dejavu.MergeResult,
// 可能需要重新加载部分功能
var needReloadFlashcard, needReloadOcrTexts, needReloadPlugin bool
upsertPluginSet := hashset.New()
needUnindexBoxes, needIndexBoxes := map[string]bool{}, map[string]bool{}
for _, file := range mergeResult.Upserts {
upserts = append(upserts, file.Path)
if strings.HasPrefix(file.Path, "/storage/riff/") {
@ -1425,6 +1426,9 @@ func processSyncMergeResult(exit, byHand bool, mergeResult *dejavu.MergeResult,
if strings.HasSuffix(file.Path, "/.siyuan/conf.json") {
needReloadFiletree = true
boxID := strings.TrimSuffix(strings.TrimPrefix(file.Path, "/"), "/.siyuan/conf.json")
needUnindexBoxes[boxID] = true
needIndexBoxes[boxID] = true
}
if strings.HasPrefix(file.Path, "/storage/petal/") {
@ -1456,6 +1460,8 @@ func processSyncMergeResult(exit, byHand bool, mergeResult *dejavu.MergeResult,
if strings.HasSuffix(file.Path, "/.siyuan/conf.json") {
needReloadFiletree = true
boxID := strings.TrimSuffix(strings.TrimPrefix(file.Path, "/"), "/.siyuan/conf.json")
needUnindexBoxes[boxID] = true
}
if strings.HasPrefix(file.Path, "/storage/petal/") {
@ -1509,6 +1515,20 @@ func processSyncMergeResult(exit, byHand bool, mergeResult *dejavu.MergeResult,
return
}
for boxID := range needUnindexBoxes {
if box := Conf.GetBox(boxID); nil != box {
box.Unindex()
}
}
for boxID := range needIndexBoxes {
if box := Conf.GetBox(boxID); nil != box {
box.Index()
}
}
if 0 < len(needUnindexBoxes) || 0 < len(needIndexBoxes) {
util.ReloadUI()
}
upsertRootIDs, removeRootIDs := incReindex(upserts, removes)
go func() {
util.WaitForUILoaded()