Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
f971bf4a78
2 changed files with 40 additions and 2 deletions
|
@ -17,6 +17,7 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/rand"
|
||||
"crypto/sha256"
|
||||
"encoding/base64"
|
||||
|
@ -540,6 +541,8 @@ func syncRepo(boot, exit, byHand bool) (err error) {
|
|||
logging.LogInfof("synced data repo [ufc=%d, dfc=%d, ucc=%d, dcc=%d, ub=%s, db=%s] in [%.2fs]",
|
||||
trafficStat.UploadFileCount, trafficStat.DownloadFileCount, trafficStat.UploadChunkCount, trafficStat.DownloadChunkCount, humanize.Bytes(uint64(trafficStat.UploadBytes)), humanize.Bytes(uint64(trafficStat.DownloadBytes)), elapsed.Seconds())
|
||||
|
||||
logSyncMergeResult(mergeResult)
|
||||
|
||||
if 0 < len(mergeResult.Conflicts) {
|
||||
// 云端同步发生冲突时生成副本 https://github.com/siyuan-note/siyuan/issues/5687
|
||||
|
||||
|
@ -629,6 +632,43 @@ func syncRepo(boot, exit, byHand bool) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func logSyncMergeResult(mergeResult *dejavu.MergeResult) {
|
||||
logging.LogInfof("sync merge result [conflicts=%d, upserts=%d, removes=%d]", len(mergeResult.Conflicts), len(mergeResult.Upserts), len(mergeResult.Removes))
|
||||
if 0 < len(mergeResult.Conflicts) {
|
||||
logBuilder := bytes.Buffer{}
|
||||
for i, f := range mergeResult.Conflicts {
|
||||
logBuilder.WriteString(" ")
|
||||
logBuilder.WriteString(f.Path)
|
||||
if i < len(mergeResult.Conflicts)-1 {
|
||||
logBuilder.WriteString("\n")
|
||||
}
|
||||
}
|
||||
logging.LogInfof("sync conflicts:\n%s", logBuilder.String())
|
||||
}
|
||||
if 0 < len(mergeResult.Upserts) {
|
||||
logBuilder := bytes.Buffer{}
|
||||
for i, f := range mergeResult.Upserts {
|
||||
logBuilder.WriteString(" ")
|
||||
logBuilder.WriteString(f.Path)
|
||||
if i < len(mergeResult.Upserts)-1 {
|
||||
logBuilder.WriteString("\n")
|
||||
}
|
||||
}
|
||||
logging.LogInfof("sync merge upserts:\n%s", logBuilder.String())
|
||||
}
|
||||
if 0 < len(mergeResult.Removes) {
|
||||
logBuilder := bytes.Buffer{}
|
||||
for i, f := range mergeResult.Removes {
|
||||
logBuilder.WriteString(" ")
|
||||
logBuilder.WriteString(f.Path)
|
||||
if i < len(mergeResult.Removes)-1 {
|
||||
logBuilder.WriteString("\n")
|
||||
}
|
||||
}
|
||||
logging.LogInfof("sync merge removes:\n%s", logBuilder.String())
|
||||
}
|
||||
}
|
||||
|
||||
func needFullReindex(upsertTrees int) bool {
|
||||
return 0.2 < float64(upsertTrees)/float64(treenode.CountTrees())
|
||||
}
|
||||
|
|
|
@ -138,8 +138,6 @@ func incReindex(upserts, removes []string) {
|
|||
util.PushEndlessProgress(msg)
|
||||
}
|
||||
|
||||
logging.LogDebugf("sync reindex [upserts=%d, removes=%d]", len(upserts), len(removes))
|
||||
|
||||
// 先执行 remove,否则移动文档时 upsert 会被忽略,导致未被索引
|
||||
bootProgressPart := 10 / float64(len(removes))
|
||||
for _, removeFile := range removes {
|
||||
|
|
Loading…
Add table
Reference in a new issue