🎨 改进多设备同时同步数据的可靠性 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

@ -1072,6 +1072,10 @@
"182": "Sharing document, please wait...",
"183": "Validating index document tree [%d/%d %s]",
"184": "Powered by <a href=\"https://b3log.org/siyuan\" target=\"_blank\">SiYuan</a>",
"185": "Index verification complete"
"185": "Index verification complete",
"186": "Locking cloud sync directory",
"187": "Unlocking cloud sync directory",
"188": "Failed to lock the cloud sync directory, please try again later",
"189": "Cloud sync directory is still locked by other devices, please try again later"
}
}

View file

@ -1072,6 +1072,10 @@
"182": "Compartiendo documento, por favor espere...",
"183": "Validando el árbol del documento de índice [%d/%d %s]",
"184": "Con la tecnología de <a href=\"https://b3log.org/siyuan\" target=\"_blank\">SiYuan</a>",
"185": "Verificación de índice completada"
"185": "Verificación de índice completada",
"186": "Bloqueando el directorio de sincronización de la nube",
"187": "Desbloqueando el directorio de sincronización en la nube",
"188": "Error al bloquear el directorio de sincronizaci\u00f3n en la nube, int\u00e1ntelo de nuevo m\u00e1s tarde",
"189": "El directorio de sincronización en la nube todavía está bloqueado por otros dispositivos, inténtalo de nuevo más tarde"
}
}

View file

@ -1072,6 +1072,10 @@
"182": "Partage du document, veuillez patienter...",
"183": "Validation de l'arborescence du document d'index [%d/%d %s]",
"184": "Propulsé par <a href=\"https://b3log.org/siyuan\" target=\"_blank\">SiYuan</a>",
"185": "Vérification de l'index terminée"
"185": "Vérification de l'index terminée",
"186": "Verrouillage du répertoire de synchronisation cloud",
"187": "Déverrouillage du répertoire de synchronisation cloud",
"188": "Échec du verrouillage du répertoire de synchronisation cloud, veuillez réessayer plus tard",
"189": "Le répertoire de synchronisation cloud est toujours verrouillé par d'autres appareils, veuillez réessayer plus tard"
}
}

View file

@ -1072,6 +1072,10 @@
"182": "正在分享文檔,請稍等...",
"183": "正在校驗索引文檔樹 [%d/%d %s]",
"184": "由<a href=\"https://b3log.org/siyuan\" target=\"_blank\">思源筆記</a>強力驅動",
"185": "索引校驗完畢"
"185": "索引校驗完畢",
"186": "正在鎖定雲端同步目錄",
"187": "正在解鎖雲端同步目錄",
"188": "鎖定雲端同步目錄失敗,請稍後再試",
"189": "雲端同步目錄還在被其他設備鎖定,請稍後再試"
}
}

View file

@ -1072,6 +1072,10 @@
"182": "正在分享文档,请稍等...",
"183": "正在校验索引文档树 [%d/%d %s]",
"184": "由<a href=\"https://b3log.org/siyuan\" target=\"_blank\">思源笔记</a>强力驱动",
"185": "索引校验完毕"
"185": "索引校验完毕",
"186": "正在锁定云端同步目录",
"187": "正在解锁云端同步目录",
"188": "锁定云端同步目录失败,请稍后再试",
"189": "云端同步目录还在被其他设备锁定,请稍后再试"
}
}

View file

@ -40,9 +40,9 @@ require (
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/radovskyb/watcher v1.0.7
github.com/shirou/gopsutil/v3 v3.23.1
github.com/siyuan-note/dejavu v0.0.0-20230203032858-f307dcd7c8fc
github.com/siyuan-note/dejavu v0.0.0-20230203091000-b288dbd9185f
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75
github.com/siyuan-note/eventbus v0.0.0-20230126092943-c6bf51e65ae2
github.com/siyuan-note/eventbus v0.0.0-20230203085647-fb624740be03
github.com/siyuan-note/filelock v0.0.0-20221117095924-e1947438a35e
github.com/siyuan-note/httpclient v0.0.0-20230201041143-5c2b2b88b985
github.com/siyuan-note/logging v0.0.0-20221031125421-9b7234d79d8a

View file

@ -383,12 +383,12 @@ github.com/shurcooL/reactions v0.0.0-20181006231557-f2e0b4ca5b82/go.mod h1:TCR1l
github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/shurcooL/users v0.0.0-20180125191416-49c67e49c537/go.mod h1:QJTqeLYEDaXHZDBsXlPCDqdhQuJkuw4NOtaxYe3xii4=
github.com/shurcooL/webdavfs v0.0.0-20170829043945-18c3829fa133/go.mod h1:hKmq5kWdCj2z2KEozexVbfEZIWiTjhE0+UjmZgPqehw=
github.com/siyuan-note/dejavu v0.0.0-20230203032858-f307dcd7c8fc h1:qpwZUhFtYSd8tezE1XIvjYUsEpGHBog0n005lMwzyfg=
github.com/siyuan-note/dejavu v0.0.0-20230203032858-f307dcd7c8fc/go.mod h1:MUYgbXnGa+ZyyaYtoo9qkXNEDUYbhRMDMSMvu8OGhSA=
github.com/siyuan-note/dejavu v0.0.0-20230203091000-b288dbd9185f h1:gQmmnpPAOEfOFj/zjanPDznw+nwRItpaKgvoU/dAiXA=
github.com/siyuan-note/dejavu v0.0.0-20230203091000-b288dbd9185f/go.mod h1:Hp/96PrZAiG2zSscNbrdu8Iyzw4nCIu2/fOtzNVtbpU=
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75 h1:Bi7/7f29LW+Fm0cHc0J1NO1cZqyJwljSWVmfOqVZgaE=
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75/go.mod h1:H8fyqqAbp9XreANjeSbc72zEdFfKTXYN34tc1TjZwtw=
github.com/siyuan-note/eventbus v0.0.0-20230126092943-c6bf51e65ae2 h1:njoj0265FOHRjF/O1aWDzdwEdYdLTZwhbuPd/hoLJT0=
github.com/siyuan-note/eventbus v0.0.0-20230126092943-c6bf51e65ae2/go.mod h1:Sqo4FYX5lAXu7gWkbEdJF0e6P57tNNVV4WDKYDctokI=
github.com/siyuan-note/eventbus v0.0.0-20230203085647-fb624740be03 h1:W7nGGluE6sBrFSVkmucGsh2NruleOPsQle7fcAW115o=
github.com/siyuan-note/eventbus v0.0.0-20230203085647-fb624740be03/go.mod h1:Sqo4FYX5lAXu7gWkbEdJF0e6P57tNNVV4WDKYDctokI=
github.com/siyuan-note/filelock v0.0.0-20221117095924-e1947438a35e h1:i3RKrdrddr4AuaHJtoWYAEVNuR7Y9wIsEqPmuFFbJC4=
github.com/siyuan-note/filelock v0.0.0-20221117095924-e1947438a35e/go.mod h1:NmpSIVtIGy8eNWapjDIiiCw5+5r5wxC76k40oG+WRXQ=
github.com/siyuan-note/httpclient v0.0.0-20230201041143-5c2b2b88b985 h1:L5NArfUHYrY43OQ1dreuzuBe8UXP2an94AYqk553f+w=

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