mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🎨 Error notification pops up only once after auto sync fails https://github.com/siyuan-note/siyuan/issues/8096
This commit is contained in:
parent
0fc3f045e0
commit
2a8378c327
4 changed files with 30 additions and 25 deletions
|
|
@ -1046,7 +1046,7 @@
|
|||
"121": "該文檔中不存在網絡圖片",
|
||||
"123": "新增/選擇雲端同步目錄後才能啟用同步功能",
|
||||
"124": "請在 [設置 - 啟用雲端同步] 中開啟雲端同步",
|
||||
"125": "自動同步下載失敗次數過多,請嘗試手動觸發同步,如果還有問題請<a href=\"https://ld246.com/article/1649901726096\" target=\"_blank\">回饋</a>",
|
||||
"125": "自動同步失敗次數過多,請嘗試手動觸發同步,如果還有問題請<a href=\"https://ld246.com/article/1649901726096\" target=\"_blank\">回饋</a>",
|
||||
"126": "書籤不能為空",
|
||||
"127": "訂閱距過期還剩 [%d] 天,過期後雲端數據會被徹底刪除。續訂請訪問<a target='_blank' href='https://ld246.com/subscribe/siyuan'>這裡</a>",
|
||||
"128": "訂閱已經過期,過期後雲端數據會被徹底刪除,訂閱過期兩天后不再彈出該提醒,續訂請訪問<a target='_blank' href='https://ld246.com/subscribe/siyuan'>這裡</a>",
|
||||
|
|
|
|||
|
|
@ -1048,7 +1048,7 @@
|
|||
"122": "该功能需在思源桌面端进行配置。如果你已经配置,请在顶部账号设置中进行刷新",
|
||||
"123": "添加/选择云端同步目录后才能启用同步功能",
|
||||
"124": "请在 [设置 - 启用云端同步] 中开启云端同步",
|
||||
"125": "自动同步下载失败次数过多,请尝试手动触发同步,如果还有问题请<a href=\"https://ld246.com/article/1649901726096\" target=\"_blank\">反馈</a>",
|
||||
"125": "自动同步失败次数过多,请尝试手动触发同步,如果还有问题请<a href=\"https://ld246.com/article/1649901726096\" target=\"_blank\">反馈</a>",
|
||||
"126": "书签不能为空",
|
||||
"127": "订阅距过期还剩 [%d] 天,过期后云端数据会被彻底删除。续订请访问<a target='_blank' href='https://ld246.com/subscribe/siyuan'>这里</a>",
|
||||
"128": "订阅已经过期,过期后云端数据会被彻底删除,订阅过期两天后不再弹出该提醒,续订请访问<a target='_blank' href='https://ld246.com/subscribe/siyuan'>这里</a>",
|
||||
|
|
|
|||
|
|
@ -902,7 +902,7 @@ func syncRepoDownload() (err error) {
|
|||
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)))
|
||||
Conf.Sync.Stat = msg
|
||||
syncDownloadErrCount = 0
|
||||
autoSyncErrCount = 0
|
||||
logging.LogInfof("synced data repo download [provider=%d, ufc=%d, dfc=%d, ucc=%d, dcc=%d, ub=%s, db=%s] in [%.2fs]",
|
||||
Conf.Sync.Provider, trafficStat.UploadFileCount, trafficStat.DownloadFileCount, trafficStat.UploadChunkCount, trafficStat.DownloadChunkCount, humanize.Bytes(uint64(trafficStat.UploadBytes)), humanize.Bytes(uint64(trafficStat.DownloadBytes)), elapsed.Seconds())
|
||||
|
||||
|
|
@ -969,6 +969,7 @@ func syncRepoUpload() (err error) {
|
|||
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)))
|
||||
Conf.Sync.Stat = msg
|
||||
autoSyncErrCount = 0
|
||||
logging.LogInfof("synced data repo upload [provider=%d, ufc=%d, dfc=%d, ucc=%d, dcc=%d, ub=%s, db=%s] in [%.2fs]",
|
||||
Conf.Sync.Provider, trafficStat.UploadFileCount, trafficStat.DownloadFileCount, trafficStat.UploadChunkCount, trafficStat.DownloadChunkCount, humanize.Bytes(uint64(trafficStat.UploadBytes)), humanize.Bytes(uint64(trafficStat.DownloadBytes)), elapsed.Seconds())
|
||||
return
|
||||
|
|
@ -976,7 +977,7 @@ func syncRepoUpload() (err error) {
|
|||
|
||||
func bootSyncRepo() (err error) {
|
||||
if 1 > len(Conf.Repo.Key) {
|
||||
syncDownloadErrCount++
|
||||
autoSyncErrCount++
|
||||
planSyncAfter(fixSyncInterval)
|
||||
|
||||
msg := Conf.Language(26)
|
||||
|
|
@ -988,7 +989,7 @@ func bootSyncRepo() (err error) {
|
|||
|
||||
repo, err := newRepository()
|
||||
if nil != err {
|
||||
syncDownloadErrCount++
|
||||
autoSyncErrCount++
|
||||
planSyncAfter(fixSyncInterval)
|
||||
|
||||
msg := fmt.Sprintf("sync repo failed: %s", err)
|
||||
|
|
@ -1001,7 +1002,7 @@ func bootSyncRepo() (err error) {
|
|||
start := time.Now()
|
||||
err = indexRepoBeforeCloudSync(repo)
|
||||
if nil != err {
|
||||
syncDownloadErrCount++
|
||||
autoSyncErrCount++
|
||||
planSyncAfter(fixSyncInterval)
|
||||
return
|
||||
}
|
||||
|
|
@ -1032,7 +1033,7 @@ func bootSyncRepo() (err error) {
|
|||
elapsed := time.Since(start)
|
||||
logging.LogInfof("boot get sync cloud files elapsed [%.2fs]", elapsed.Seconds())
|
||||
if nil != err {
|
||||
syncDownloadErrCount++
|
||||
autoSyncErrCount++
|
||||
planSyncAfter(fixSyncInterval)
|
||||
|
||||
logging.LogErrorf("sync data repo failed: %s", err)
|
||||
|
|
@ -1067,7 +1068,7 @@ func bootSyncRepo() (err error) {
|
|||
|
||||
func syncRepo(exit, byHand bool) (err error) {
|
||||
if 1 > len(Conf.Repo.Key) {
|
||||
syncDownloadErrCount++
|
||||
autoSyncErrCount++
|
||||
planSyncAfter(fixSyncInterval)
|
||||
|
||||
msg := Conf.Language(26)
|
||||
|
|
@ -1079,7 +1080,7 @@ func syncRepo(exit, byHand bool) (err error) {
|
|||
|
||||
repo, err := newRepository()
|
||||
if nil != err {
|
||||
syncDownloadErrCount++
|
||||
autoSyncErrCount++
|
||||
planSyncAfter(fixSyncInterval)
|
||||
|
||||
msg := fmt.Sprintf("sync repo failed: %s", err)
|
||||
|
|
@ -1092,7 +1093,7 @@ func syncRepo(exit, byHand bool) (err error) {
|
|||
start := time.Now()
|
||||
err = indexRepoBeforeCloudSync(repo)
|
||||
if nil != err {
|
||||
syncDownloadErrCount++
|
||||
autoSyncErrCount++
|
||||
planSyncAfter(fixSyncInterval)
|
||||
return
|
||||
}
|
||||
|
|
@ -1107,7 +1108,7 @@ func syncRepo(exit, byHand bool) (err error) {
|
|||
}
|
||||
elapsed := time.Since(start)
|
||||
if nil != err {
|
||||
syncDownloadErrCount++
|
||||
autoSyncErrCount++
|
||||
planSyncAfter(fixSyncInterval)
|
||||
|
||||
logging.LogErrorf("sync data repo failed: %s", err)
|
||||
|
|
@ -1120,7 +1121,9 @@ func syncRepo(exit, byHand bool) (err error) {
|
|||
}
|
||||
Conf.Sync.Stat = msg
|
||||
util.PushStatusBar(msg)
|
||||
if 1 > autoSyncErrCount || byHand {
|
||||
util.PushErrMsg(msg, 0)
|
||||
}
|
||||
if exit {
|
||||
ExitSyncSucc = 1
|
||||
}
|
||||
|
|
@ -1131,7 +1134,7 @@ func syncRepo(exit, byHand bool) (err error) {
|
|||
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)))
|
||||
Conf.Sync.Stat = msg
|
||||
syncDownloadErrCount = 0
|
||||
autoSyncErrCount = 0
|
||||
logging.LogInfof("synced data repo [provider=%d, ufc=%d, dfc=%d, ucc=%d, dcc=%d, ub=%s, db=%s] in [%.2fs]",
|
||||
Conf.Sync.Provider, trafficStat.UploadFileCount, trafficStat.DownloadFileCount, trafficStat.UploadChunkCount, trafficStat.DownloadChunkCount, humanize.Bytes(uint64(trafficStat.UploadBytes)), humanize.Bytes(uint64(trafficStat.DownloadBytes)), elapsed.Seconds())
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ func SyncDataDownload() {
|
|||
}
|
||||
|
||||
util.BroadcastByType("main", "syncing", 0, Conf.Language(81), nil)
|
||||
if !isProviderOnline() { // 这个操作比较耗时,所以要先推送 syncing 事件后再判断网络,这样才能给用户更即时的反馈
|
||||
if !isProviderOnline(true) { // 这个操作比较耗时,所以要先推送 syncing 事件后再判断网络,这样才能给用户更即时的反馈
|
||||
util.BroadcastByType("main", "syncing", 2, Conf.Language(28), nil)
|
||||
return
|
||||
}
|
||||
|
|
@ -82,7 +82,7 @@ func SyncDataUpload() {
|
|||
}
|
||||
|
||||
util.BroadcastByType("main", "syncing", 0, Conf.Language(81), nil)
|
||||
if !isProviderOnline() { // 这个操作比较耗时,所以要先推送 syncing 事件后再判断网络,这样才能给用户更即时的反馈
|
||||
if !isProviderOnline(true) { // 这个操作比较耗时,所以要先推送 syncing 事件后再判断网络,这样才能给用户更即时的反馈
|
||||
util.BroadcastByType("main", "syncing", 2, Conf.Language(28), nil)
|
||||
return
|
||||
}
|
||||
|
|
@ -113,7 +113,7 @@ func SyncDataUpload() {
|
|||
|
||||
var (
|
||||
syncSameCount = 0
|
||||
syncDownloadErrCount = 0
|
||||
autoSyncErrCount = 0
|
||||
fixSyncInterval = 5 * time.Minute
|
||||
syncPlanTime = time.Now().Add(fixSyncInterval)
|
||||
|
||||
|
|
@ -136,7 +136,7 @@ func BootSyncData() {
|
|||
return
|
||||
}
|
||||
|
||||
if !isProviderOnline() {
|
||||
if !isProviderOnline(false) {
|
||||
BootSyncSucc = 1
|
||||
util.PushErrMsg(Conf.Language(28), 7000)
|
||||
return
|
||||
|
|
@ -182,7 +182,7 @@ func syncData(exit, byHand bool) {
|
|||
}
|
||||
|
||||
util.BroadcastByType("main", "syncing", 0, Conf.Language(81), nil)
|
||||
if !exit && !isProviderOnline() { // 这个操作比较耗时,所以要先推送 syncing 事件后再判断网络,这样才能给用户更即时的反馈
|
||||
if !exit && !isProviderOnline(byHand) { // 这个操作比较耗时,所以要先推送 syncing 事件后再判断网络,这样才能给用户更即时的反馈
|
||||
util.BroadcastByType("main", "syncing", 2, Conf.Language(28), nil)
|
||||
return
|
||||
}
|
||||
|
|
@ -250,8 +250,8 @@ func checkSync(boot, exit, byHand bool) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
if 7 < syncDownloadErrCount && !byHand {
|
||||
logging.LogErrorf("sync download error too many times, cancel auto sync, try to sync by hand")
|
||||
if 7 < autoSyncErrCount && !byHand {
|
||||
logging.LogErrorf("failed to auto-sync too many times, delay auto-sync 64 minutes")
|
||||
util.PushErrMsg(Conf.Language(125), 1000*60*60)
|
||||
planSyncAfter(64 * time.Minute)
|
||||
return false
|
||||
|
|
@ -561,7 +561,7 @@ func planSyncAfter(d time.Duration) {
|
|||
syncPlanTime = time.Now().Add(d)
|
||||
}
|
||||
|
||||
func isProviderOnline() (ret bool) {
|
||||
func isProviderOnline(byHand bool) (ret bool) {
|
||||
checkURL := util.SiYuanSyncServer
|
||||
skipTlsVerify := false
|
||||
switch Conf.Sync.Provider {
|
||||
|
|
@ -578,7 +578,9 @@ func isProviderOnline() (ret bool) {
|
|||
}
|
||||
|
||||
if ret = util.IsOnline(checkURL, skipTlsVerify); !ret {
|
||||
util.PushErrMsg(Conf.Language(76) + " (Provider: " + conf.ProviderToStr(Conf.Sync.Provider) + ")", 5000)
|
||||
if 1 > autoSyncErrCount || byHand {
|
||||
util.PushErrMsg(Conf.Language(76)+" (Provider: "+conf.ProviderToStr(Conf.Sync.Provider)+")", 5000)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue