🎨 改进多设备同时同步数据的可靠性 https://github.com/siyuan-note/siyuan/issues/7245

This commit is contained in:
Liang Ding 2023-02-03 17:18:38 +08:00
parent 6e8a4bbf71
commit 85771e1a45
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
10 changed files with 48 additions and 13 deletions

View file

@ -215,7 +215,7 @@ func InitConf() {
if "" == Conf.System.ID {
Conf.System.ID = util.GetDeviceID()
}
if "std" == util.Container {
if util.ContainerStd == util.Container {
Conf.System.ID = util.GetDeviceID()
}

View file

@ -927,6 +927,7 @@ func syncRepo(exit, byHand bool) (err error) {
}
return
}
util.PushStatusBar(fmt.Sprintf(Conf.Language(149), elapsed.Seconds()))
Conf.Sync.Synced = util.CurrentTimeMillis()
msg := fmt.Sprintf(Conf.Language(150), trafficStat.UploadFileCount, trafficStat.DownloadFileCount, trafficStat.UploadChunkCount, trafficStat.DownloadChunkCount, humanize.Bytes(uint64(trafficStat.UploadBytes)), humanize.Bytes(uint64(trafficStat.DownloadBytes)))
@ -1185,7 +1186,7 @@ func newRepository() (ret *dejavu.Repo, err error) {
ignoreLines := getIgnoreLines()
ignoreLines = append(ignoreLines, "/.siyuan/conf.json") // 忽略旧版同步配置
ret, err = dejavu.NewRepo(util.DataDir, util.RepoDir, util.HistoryDir, util.TempDir, Conf.Repo.Key, ignoreLines, cloudRepo)
ret, err = dejavu.NewRepo(util.DataDir, util.RepoDir, util.HistoryDir, util.TempDir, Conf.System.ID, Conf.Repo.Key, ignoreLines, cloudRepo)
if nil != err {
logging.LogErrorf("init data repo failed: %s", err)
return
@ -1363,6 +1364,16 @@ func subscribeEvents() {
util.SetBootDetails(msg)
util.ContextPushMsg(context, msg)
})
eventbus.Subscribe(eventbus.EvtCloudLock, func(context map[string]interface{}) {
msg := fmt.Sprintf(Conf.Language(186))
util.SetBootDetails(msg)
util.ContextPushMsg(context, msg)
})
eventbus.Subscribe(eventbus.EvtCloudUnlock, func(context map[string]interface{}) {
msg := fmt.Sprintf(Conf.Language(187))
util.SetBootDetails(msg)
util.ContextPushMsg(context, msg)
})
}
func buildCloudConf() (ret *cloud.Conf, err error) {

View file

@ -437,6 +437,10 @@ func formatErrorMsg(err error) string {
msg = Conf.Language(28)
} else if strings.Contains(msgLowerCase, "cloud object not found") {
msg = Conf.Language(129)
} else if strings.Contains(msgLowerCase, "lock cloud repo failed") {
msg = Conf.Language(188)
} else if strings.Contains(msgLowerCase, "cloud repo is locked") {
msg = Conf.Language(189)
}
msg = msg + " v" + util.Ver
return msg