From 7f9d6ecd29d8d5661049d8fb86c54b20272d7b5a Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Fri, 16 Jun 2023 09:25:59 +0800 Subject: [PATCH] :art: Display data sync progress in the status bar https://github.com/siyuan-note/siyuan/issues/8552 --- app/appearance/langs/en_US.json | 2 +- app/appearance/langs/es_ES.json | 2 +- app/appearance/langs/fr_FR.json | 2 +- app/appearance/langs/zh_CHT.json | 2 +- app/appearance/langs/zh_CN.json | 2 +- kernel/go.mod | 2 +- kernel/model/repository.go | 35 ++++++++++++-------------------- 7 files changed, 19 insertions(+), 28 deletions(-) diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.json index 6b95509d4..49809837c 100644 --- a/app/appearance/langs/en_US.json +++ b/app/appearance/langs/en_US.json @@ -1123,7 +1123,7 @@ "156": "Access authentication failed, please refresh the page", "157": "The key is not recognized, please confirm that the copied key string is correct", "158": "Indexing data repo, walking data %s", - "159": "Indexing data repo, getting the latest file %v", + "159": "Indexing data repo, getting the latest file %v/%v", "160": "Indexing data repo, inserting file %v", "161": "Checking out of data repo, walking data %s", "162": "Checking out data repo, inserting file %v/%v", diff --git a/app/appearance/langs/es_ES.json b/app/appearance/langs/es_ES.json index 257cade1d..e568a7609 100644 --- a/app/appearance/langs/es_ES.json +++ b/app/appearance/langs/es_ES.json @@ -1123,7 +1123,7 @@ "156": "Error en la autenticación de acceso, actualice la página", "157": "No se reconoce la clave, confirme que la cadena de clave copiada es correcta", "158": "Indexando repositorio de datos, datos para caminar %s", - "159": "Indexando repositorio de datos, obteniendo el último archivo %v", + "159": "Indexando repositorio de datos, obteniendo el último archivo %v/%v", "160": "Indexando repositorio de datos, insertando archivo %v", "161": "Revisando el repositorio de datos, recorriendo datos %s", "162": "Revisando el repositorio de datos, insertando el archivo %v/%v", diff --git a/app/appearance/langs/fr_FR.json b/app/appearance/langs/fr_FR.json index 6cac586fb..7dfce915e 100644 --- a/app/appearance/langs/fr_FR.json +++ b/app/appearance/langs/fr_FR.json @@ -1123,7 +1123,7 @@ "156": "Échec de l'authentification d'accès, veuillez actualiser la page", "157": "La clé n'est pas reconnue, veuillez confirmer que la chaîne de clé copiée est correcte", "158": "Indexation du référentiel de données, données de marche %s", - "159": "Indexation du référentiel de données, obtention du dernier fichier %v", + "159": "Indexation du référentiel de données, obtention du dernier fichier %v/%v", "160": "Indexation du référentiel de données, insertion du fichier %v", "161": "Vérification du référentiel de données, données piétonnes %s", "162": "Vérification du référentiel de données, insertion du fichier %v/%v", diff --git a/app/appearance/langs/zh_CHT.json b/app/appearance/langs/zh_CHT.json index e2b9cb63c..3691f6ef4 100644 --- a/app/appearance/langs/zh_CHT.json +++ b/app/appearance/langs/zh_CHT.json @@ -1123,7 +1123,7 @@ "156": "訪問鑑權失敗,請刷新頁面", "157": "無法識別密鑰,請確認複製的密鑰字串是否正確", "158": "正在索引數據倉庫,遍歷數據 %s", - "159": "正在索引數據倉庫,獲取最新文件 %v", + "159": "正在索引數據倉庫,獲取最新文件 %v/%v", "160": "正在索引數據倉庫,插入文件 %v", "161": "正在遷出數據倉庫,遍歷數據 %s", "162": "正在遷出數據倉庫,插入文件 %v/%v", diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.json index 807ab1938..c655d1a5d 100644 --- a/app/appearance/langs/zh_CN.json +++ b/app/appearance/langs/zh_CN.json @@ -1125,7 +1125,7 @@ "156": "访问鉴权失败,请刷新页面", "157": "无法识别密钥,请确认复制的密钥字符串是否正确", "158": "正在索引数据仓库,遍历数据 %s", - "159": "正在索引数据仓库,获取最新文件 %v", + "159": "正在索引数据仓库,获取最新文件 %v/%v", "160": "正在索引数据仓库,插入文件 %v", "161": "正在迁出数据仓库,遍历数据 %s", "162": "正在迁出数据仓库,插入文件 %v/%v", diff --git a/kernel/go.mod b/kernel/go.mod index d78c08751..31d3cd2b4 100644 --- a/kernel/go.mod +++ b/kernel/go.mod @@ -144,7 +144,7 @@ require ( replace github.com/mattn/go-sqlite3 => github.com/88250/go-sqlite3 v1.14.13-0.20220714142610-fbbda1ee84f5 -//replace github.com/siyuan-note/dejavu => D:\88250\dejavu +replace github.com/siyuan-note/dejavu => D:\88250\dejavu //replace github.com/siyuan-note/riff => D:\88250\riff //replace github.com/siyuan-note/httpclient => D:\88250\httpclient //replace github.com/siyuan-note/filelock => D:\88250\filelock diff --git a/kernel/model/repository.go b/kernel/model/repository.go index 871a87d36..b326dd1f1 100644 --- a/kernel/model/repository.go +++ b/kernel/model/repository.go @@ -1492,19 +1492,18 @@ func subscribeRepoEvents() { } indexWalkDataCount++ }) - eventbus.Subscribe(eventbus.EvtIndexBeforeGetLatestFiles, func(context map[string]interface{}, files []string) { - msg := fmt.Sprintf(Conf.Language(159), len(files)) + eventbus.Subscribe(eventbus.EvtIndexBeforeGetLatestFiles, func(context map[string]interface{}, total int) { + msg := fmt.Sprintf(Conf.Language(159), 0, total) util.SetBootDetails(msg) util.ContextPushMsg(context, msg) }) - getLatestFileCount := 0 - eventbus.Subscribe(eventbus.EvtIndexGetLatestFile, func(context map[string]interface{}, id string) { - msg := fmt.Sprintf(Conf.Language(159), id[:7]) - if 0 == getLatestFileCount%1024 { + + eventbus.Subscribe(eventbus.EvtIndexGetLatestFile, func(context map[string]interface{}, count int, total int) { + msg := fmt.Sprintf(Conf.Language(159), count, total) + if 0 == count%64 { util.SetBootDetails(msg) util.ContextPushMsg(context, msg) } - getLatestFileCount++ }) eventbus.Subscribe(eventbus.EvtIndexUpsertFiles, func(context map[string]interface{}, files []*entity.File) { msg := fmt.Sprintf(Conf.Language(160), len(files)) @@ -1557,14 +1556,13 @@ func subscribeRepoEvents() { bootProgressPart = 10 / float64(total) util.ContextPushMsg(context, msg) }) - coRemoveFileCount := 0 + eventbus.Subscribe(eventbus.EvtCheckoutRemoveFile, func(context map[string]interface{}, count, total int) { msg := fmt.Sprintf(Conf.Language(163), count, total) util.IncBootProgress(bootProgressPart, msg) - if 0 == coRemoveFileCount%1024 { + if 0 == count%64 { util.ContextPushMsg(context, msg) } - coRemoveFileCount++ }) eventbus.Subscribe(eventbus.EvtCloudBeforeDownloadIndex, func(context map[string]interface{}, id string) { @@ -1579,14 +1577,13 @@ func subscribeRepoEvents() { bootProgressPart = 10 / float64(total) util.ContextPushMsg(context, msg) }) - downloadFileCount := 0 + eventbus.Subscribe(eventbus.EvtCloudBeforeDownloadFile, func(context map[string]interface{}, count, total int) { msg := fmt.Sprintf(Conf.Language(165), count, total) util.IncBootProgress(bootProgressPart, msg) - if 0 == downloadFileCount%8 { + if 0 == count%8 { util.ContextPushMsg(context, msg) } - downloadFileCount++ }) eventbus.Subscribe(eventbus.EvtCloudBeforeDownloadChunks, func(context map[string]interface{}, total int) { msg := fmt.Sprintf(Conf.Language(166), 0, total) @@ -1594,14 +1591,12 @@ func subscribeRepoEvents() { bootProgressPart = 10 / float64(total) util.ContextPushMsg(context, msg) }) - downloadChunkCount := 0 eventbus.Subscribe(eventbus.EvtCloudBeforeDownloadChunk, func(context map[string]interface{}, count, total int) { msg := fmt.Sprintf(Conf.Language(166), count, total) util.IncBootProgress(bootProgressPart, msg) - if 0 == downloadChunkCount%8 { + if 0 == count%8 { util.ContextPushMsg(context, msg) } - downloadChunkCount++ }) eventbus.Subscribe(eventbus.EvtCloudBeforeDownloadRef, func(context map[string]interface{}, ref string) { msg := fmt.Sprintf(Conf.Language(167), ref) @@ -1618,28 +1613,24 @@ func subscribeRepoEvents() { util.SetBootDetails(msg) util.ContextPushMsg(context, msg) }) - uploadFileCount := 0 eventbus.Subscribe(eventbus.EvtCloudBeforeUploadFile, func(context map[string]interface{}, count, total int) { msg := fmt.Sprintf(Conf.Language(169), count, total) - if 0 == uploadFileCount%8 { + if 0 == count%8 { util.SetBootDetails(msg) util.ContextPushMsg(context, msg) } - uploadFileCount++ }) eventbus.Subscribe(eventbus.EvtCloudBeforeUploadChunks, func(context map[string]interface{}, total int) { msg := fmt.Sprintf(Conf.Language(170), 0, total) util.SetBootDetails(msg) util.ContextPushMsg(context, msg) }) - uploadChunkCount := 0 eventbus.Subscribe(eventbus.EvtCloudBeforeUploadChunk, func(context map[string]interface{}, count, total int) { msg := fmt.Sprintf(Conf.Language(170), count, total) - if 0 == uploadChunkCount%8 { + if 0 == count%8 { util.SetBootDetails(msg) util.ContextPushMsg(context, msg) } - uploadChunkCount++ }) eventbus.Subscribe(eventbus.EvtCloudBeforeUploadRef, func(context map[string]interface{}, ref string) { msg := fmt.Sprintf(Conf.Language(171), ref)