🎨 改进桌面端底部状态栏通知 Fix https://github.com/siyuan-note/siyuan/issues/5294

This commit is contained in:
Liang Ding 2022-06-26 20:49:00 +08:00
parent cdeda3f076
commit 5ca22dc691
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
5 changed files with 39 additions and 12 deletions

View file

@ -896,6 +896,9 @@
"143": "Creating data snapshot...",
"144": "Resetting data repository...",
"145": "Data repository reset completed",
"146": "Failed to reset data repository: %s"
"146": "Failed to reset data repository: %s",
"147": "Created a new data snapshot, took %.2fs",
"148": "Checked the data snapshot and found no changes",
"149": "Data snapshot has been synchronized, took %.2fs"
}
}

View file

@ -896,6 +896,9 @@
"143": "Création d'un instantané de données...",
"144": "Réinitialisation du référentiel de données...",
"145": "Réinitialisation du référentiel de données terminée",
"146": "Échec de la réinitialisation du référentiel de données : %s"
"146": "Échec de la réinitialisation du référentiel de données : %s",
"147": "Créé un nouvel instantané de données, a pris %.2fs",
"148": "Vérifié l'instantané des données et n'a trouvé aucun changement",
"149": "L'instantané des données a été synchronisé, a pris %.2fs"
}
}

View file

@ -895,6 +895,9 @@
"143": "正在創建數據快照...",
"144": "正在重置數據倉庫...",
"145": "數據倉庫重置完畢",
"146": "重置數據倉庫失敗:%s"
"146": "重置數據倉庫失敗:%s",
"147": "創建了一個新的數據快照,耗時 %.2fs",
"148": "檢查數據快照,沒有發現任何變化",
"149": "已經同步數據快照,耗時 %.2fs"
}
}

View file

@ -897,6 +897,9 @@
"143": "正在创建数据快照...",
"144": "正在重置数据仓库...",
"145": "数据仓库重置完毕",
"146": "重置数据仓库失败:%s"
"146": "重置数据仓库失败:%s",
"147": "创建了一个新的数据快照,耗时 %.2fs",
"148": "检查数据快照,没有发现任何变化",
"149": "已经同步数据快照,耗时 %.2fs"
}
}

View file

@ -360,15 +360,27 @@ func IndexRepo(memo string) (err error) {
defer writingDataLock.Unlock()
start := time.Now()
latest, _ := repo.Latest()
WaitForWritingFiles()
sql.WaitForWritingDatabase()
filelock.ReleaseAllFileLocks()
_, err = repo.Index(memo, map[string]interface{}{
index, err := repo.Index(memo, map[string]interface{}{
CtxPushMsg: CtxPushMsgToStatusBarAndProgress,
})
if nil != err {
util.PushStatusBar("Create data snapshot failed")
return
}
elapsed := time.Since(start)
util.LogInfof("index data repo elapsed [%.2fs]", elapsed.Seconds())
util.PushStatusBar(fmt.Sprintf("Indexed data repo in %.2fs", elapsed.Seconds()))
if nil != latest {
if latest.ID != index.ID {
util.PushStatusBar(fmt.Sprintf(Conf.Language(147), elapsed.Seconds()))
} else {
util.PushStatusBar(Conf.Language(148))
}
} else {
util.PushStatusBar(fmt.Sprintf(Conf.Language(147), elapsed.Seconds()))
}
util.PushClearProgress()
return
}
@ -393,11 +405,12 @@ func indexRepoBeforeCloudSync() {
}
start := time.Now()
latest, err := repo.Latest()
latest, _ := repo.Latest()
index, err := repo.Index("[Auto] Cloud sync", map[string]interface{}{
CtxPushMsg: CtxPushMsgToStatusBar,
})
if nil != err {
util.PushStatusBar("Create data snapshot for cloud sync failed")
util.LogErrorf("index data repo before cloud sync failed: %s", err)
return
}
@ -412,10 +425,12 @@ func indexRepoBeforeCloudSync() {
util.LogErrorf("put index into data repo before cloud sync failed: %s", err)
return
}
util.PushStatusBar("Made a new data snapshot for cloud sync")
util.PushStatusBar(fmt.Sprintf(Conf.Language(147), elapsed.Seconds()))
} else {
util.PushStatusBar("Checked data snapshot and found no changes ")
util.PushStatusBar(Conf.Language(148))
}
} else {
util.PushStatusBar(fmt.Sprintf(Conf.Language(147), elapsed.Seconds()))
}
if 7000 < elapsed.Milliseconds() {
util.LogWarnf("index data repo before cloud sync elapsed [%dms]", elapsed.Milliseconds())
@ -439,6 +454,6 @@ func syncRepo() (err error) {
})
elapsed := time.Since(start)
util.LogInfof("sync data repo elapsed [%.2fs]", elapsed.Seconds())
util.PushStatusBar(fmt.Sprintf("Synced data repo in %.2fs", elapsed.Seconds()))
util.PushStatusBar(fmt.Sprintf(Conf.Language(149), elapsed.Seconds()))
return
}