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

This commit is contained in:
Vanessa 2022-07-18 10:11:09 +08:00
commit cbe45ada4d
3 changed files with 22 additions and 9 deletions

View File

@ -37,6 +37,7 @@ import (
"github.com/siyuan-note/logging" "github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/cache" "github.com/siyuan-note/siyuan/kernel/cache"
"github.com/siyuan-note/siyuan/kernel/sql" "github.com/siyuan-note/siyuan/kernel/sql"
"github.com/siyuan-note/siyuan/kernel/treenode"
"github.com/siyuan-note/siyuan/kernel/util" "github.com/siyuan-note/siyuan/kernel/util"
) )
@ -520,16 +521,25 @@ func syncRepo(boot, exit, byHand bool) {
for _, file := range mergeResult.Removes { for _, file := range mergeResult.Removes {
removes = append(removes, file.Path) removes = append(removes, file.Path)
} }
incReindex(upserts, removes)
cache.ClearDocsIAL()
// 刷新界面 if boot && gulu.File.IsExist(util.BlockTreePath) {
util.ReloadUI() treenode.InitBlockTree()
}
incReindex(upserts, removes)
cache.ClearDocsIAL() // 同步后文档树文档图标没有更新 https://github.com/siyuan-note/siyuan/issues/4939
if !boot && !exit {
util.ReloadUI()
}
elapsed = time.Since(start) elapsed = time.Since(start)
go func() { if !exit {
time.Sleep(2 * time.Second) go func() {
util.PushStatusBar(fmt.Sprintf(Conf.Language(149), elapsed.Seconds())) time.Sleep(2 * time.Second)
}() util.PushStatusBar(fmt.Sprintf(Conf.Language(149), elapsed.Seconds()))
}()
}
return return
} }

View File

@ -123,6 +123,7 @@ func SyncData(boot, exit, byHand bool) {
// incReindex 增量重建索引。 // incReindex 增量重建索引。
func incReindex(upserts, removes []string) { func incReindex(upserts, removes []string) {
util.IncBootProgress(3, "Sync reindexing...")
needPushRemoveProgress := 32 < len(removes) needPushRemoveProgress := 32 < len(removes)
needPushUpsertProgress := 32 < len(upserts) needPushUpsertProgress := 32 < len(upserts)
msg := fmt.Sprintf(Conf.Language(35)) msg := fmt.Sprintf(Conf.Language(35))
@ -141,6 +142,7 @@ func incReindex(upserts, removes []string) {
id := strings.TrimSuffix(filepath.Base(removeFile), ".sy") id := strings.TrimSuffix(filepath.Base(removeFile), ".sy")
block := treenode.GetBlockTree(id) block := treenode.GetBlockTree(id)
if nil != block { if nil != block {
util.SetBootDetails("Sync remove tree " + block.Path)
treenode.RemoveBlockTreesByRootID(block.RootID) treenode.RemoveBlockTreesByRootID(block.RootID)
sql.RemoveTreeQueue(block.BoxID, block.RootID) sql.RemoveTreeQueue(block.BoxID, block.RootID)
msg = fmt.Sprintf(Conf.Language(39), block.RootID) msg = fmt.Sprintf(Conf.Language(39), block.RootID)
@ -156,7 +158,6 @@ func incReindex(upserts, removes []string) {
if needPushRemoveProgress || needPushUpsertProgress { if needPushRemoveProgress || needPushUpsertProgress {
util.PushEndlessProgress(msg) util.PushEndlessProgress(msg)
} }
sql.WaitForWritingDatabase()
for _, upsertFile := range upserts { for _, upsertFile := range upserts {
if !strings.HasSuffix(upsertFile, ".sy") { if !strings.HasSuffix(upsertFile, ".sy") {
@ -175,6 +176,7 @@ func incReindex(upserts, removes []string) {
box := upsertFile[:idx] box := upsertFile[:idx]
p := strings.TrimPrefix(upsertFile, box) p := strings.TrimPrefix(upsertFile, box)
util.SetBootDetails("Sync upsert tree " + p)
tree, err0 := LoadTree(box, p) tree, err0 := LoadTree(box, p)
if nil != err0 { if nil != err0 {
continue continue

View File

@ -302,6 +302,7 @@ func initPathDir() {
} }
} }
// TODO: v2.2.0 移除
func cleanOld() { func cleanOld() {
dirs, _ := os.ReadDir(WorkingDir) dirs, _ := os.ReadDir(WorkingDir)
for _, dir := range dirs { for _, dir := range dirs {