From 07abcd0121d3e524ff0d6ec43777bb916140e859 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Wed, 25 Jan 2023 22:08:21 +0800 Subject: [PATCH 1/4] =?UTF-8?q?:art:=20=E6=94=B9=E8=BF=9B=E5=86=85?= =?UTF-8?q?=E6=A0=B8=E4=BB=BB=E5=8A=A1=E8=B0=83=E5=BA=A6=E6=9C=BA=E5=88=B6?= =?UTF-8?q?=E6=8F=90=E5=8D=87=E7=A8=B3=E5=AE=9A=E6=80=A7=20https://github.?= =?UTF-8?q?com/siyuan-note/siyuan/issues/7113?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 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 | 4 ++-- app/appearance/langs/zh_CN.json | 2 +- kernel/api/block.go | 8 ++++---- kernel/model/block.go | 2 +- kernel/model/index.go | 6 ++++-- kernel/task/queue.go | 5 ----- 9 files changed, 15 insertions(+), 18 deletions(-) diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.json index cb5e33a48..5f05d325c 100644 --- a/app/appearance/langs/en_US.json +++ b/app/appearance/langs/en_US.json @@ -942,7 +942,7 @@ "53": "Data synchronization has not been enabled", "54": "Indexing references...", "55": "Indexed references of [%d] documents", - "56": "TODO", + "56": "Reindexing, please wait until rebuilding is complete before trying to open the document", "57": "Failed to create temp key", "58": "After the index is rebuilt, the interface will be automatically refreshed later...", "59": "Failed to set sync ignore list", diff --git a/app/appearance/langs/es_ES.json b/app/appearance/langs/es_ES.json index ca94c3a2f..8625038ab 100644 --- a/app/appearance/langs/es_ES.json +++ b/app/appearance/langs/es_ES.json @@ -942,7 +942,7 @@ "53": "No se ha habilitado la sincronizacion de datos", "54": "Indexando referencias...", "55": "Referencias indexadas de [%d] documentos", - "56": "TODO", + "56": "Reindexando, espere hasta que se complete la reconstrucción antes de intentar abrir el documento", "57": "Fallo en la creación de la clave temporal", "58": "Después de reconstruir el índice, la interfaz se actualizará automáticamente más tarde...", "59": " Falló la configuración de sincronización de la lista de ignorados", diff --git a/app/appearance/langs/fr_FR.json b/app/appearance/langs/fr_FR.json index 1bcf4e4ec..26e3bdef4 100644 --- a/app/appearance/langs/fr_FR.json +++ b/app/appearance/langs/fr_FR.json @@ -942,7 +942,7 @@ "53": "La synchronisation des données n'a pas été activée", "54": "Indexation des références...", "55": "Références indexées de [%d] documents", - "56": "TODO", + "56": "Réindexation, veuillez attendre que la reconstruction soit terminée avant d'essayer d'ouvrir le document", "57": "Échec de la création d'une clé temporaire", "58": "Une fois l'index reconstruit, l'interface sera automatiquement rafraîchie ultérieurement...", "59": "Échec de la définition de la liste des ignores de synchronisation", diff --git a/app/appearance/langs/zh_CHT.json b/app/appearance/langs/zh_CHT.json index 794698103..89209bc97 100644 --- a/app/appearance/langs/zh_CHT.json +++ b/app/appearance/langs/zh_CHT.json @@ -942,7 +942,7 @@ "53": "數據同步尚未啟用", "54": "正在索引引用關係...", "55": "已完成索引 [%d] 篇文檔的引用關係", - "56": "TODO", + "56": "正在重建索引,請等重建索引完畢後再嘗試打開該文檔", "57": "創建臨時金鑰失敗", "58": "重建索引完畢,稍後將自動重新整理介面...", "59": "設置同步忽略列表失敗", @@ -1073,4 +1073,4 @@ "184": "由思源筆記強力驅動", "185": "索引校驗完畢" } -}, +} \ No newline at end of file diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.json index e937780ff..ef6da8ce0 100644 --- a/app/appearance/langs/zh_CN.json +++ b/app/appearance/langs/zh_CN.json @@ -942,7 +942,7 @@ "53": "数据同步尚未启用", "54": "正在索引引用关系...", "55": "已完成索引 [%d] 篇文档的引用关系", - "56": "TODO", + "56": "正在重建索引,请等重建索引完毕后再尝试打开该文档", "57": "创建临时密钥失败", "58": "重建索引完毕,稍后将自动刷新界面...", "59": "设置同步忽略列表失败", diff --git a/kernel/api/block.go b/kernel/api/block.go index e355c3b85..8c01f06f9 100644 --- a/kernel/api/block.go +++ b/kernel/api/block.go @@ -175,8 +175,8 @@ func checkBlockExist(c *gin.Context) { return } if errors.Is(err, model.ErrIndexing) { - ret.Code = 3 - ret.Data = id + ret.Code = 0 + ret.Data = false return } ret.Data = nil != b @@ -384,7 +384,7 @@ func getBlockInfo(c *gin.Context) { } if errors.Is(err, model.ErrIndexing) { ret.Code = 3 - ret.Data = id + ret.Msg = model.Conf.Language(56) return } if nil == block { @@ -415,7 +415,7 @@ func getBlockInfo(c *gin.Context) { } if errors.Is(err, model.ErrIndexing) { ret.Code = 3 - ret.Data = id + ret.Data = model.Conf.Language(56) return } rootTitle := root.IAL["title"] diff --git a/kernel/model/block.go b/kernel/model/block.go index 491f1f8da..650e7f7b4 100644 --- a/kernel/model/block.go +++ b/kernel/model/block.go @@ -393,7 +393,7 @@ func getBlock(id string) (ret *Block, err error) { tree, err := loadTreeByBlockID(id) if nil != err { - if indexing { + if isIndexing() { err = ErrIndexing } return diff --git a/kernel/model/index.go b/kernel/model/index.go index 4389311ad..e664933b7 100644 --- a/kernel/model/index.go +++ b/kernel/model/index.go @@ -54,10 +54,12 @@ func (box *Box) Index() { var indexing = false -func waitForIndexing() { - for indexing { +func isIndexing() (ret bool) { + for i := 0; indexing || i > 7; i++ { time.Sleep(time.Millisecond * 100) + ret = true } + return } func index(boxID string) { diff --git a/kernel/task/queue.go b/kernel/task/queue.go index 1a5be5788..f4741c741 100644 --- a/kernel/task/queue.go +++ b/kernel/task/queue.go @@ -144,8 +144,6 @@ func StatusLoop() { } } -var taskWaitGroup = sync.WaitGroup{} - func Loop() { for { time.Sleep(10 * time.Millisecond) @@ -163,9 +161,7 @@ func Loop() { break } - taskWaitGroup.Add(1) go execTask(task) - taskWaitGroup.Wait() } } @@ -202,5 +198,4 @@ func execTask(task *Task) { } task.Handler.Call(args) - taskWaitGroup.Done() } From 664922028305e0dd3319ec522ca95533b7e91178 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Wed, 25 Jan 2023 22:46:29 +0800 Subject: [PATCH 2/4] =?UTF-8?q?:bug:=20v2.7.1-dev2=E6=9C=AA=E5=90=AF?= =?UTF-8?q?=E7=94=A8=E6=95=B0=E6=8D=AE=E5=90=8C=E6=AD=A5=E9=80=80=E5=87=BA?= =?UTF-8?q?=E6=97=B6=E6=98=BE=E7=A4=BA=E5=90=8C=E6=AD=A5=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=20Fix=20https://github.com/siyuan-note/siyuan/issues/7164?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/conf.go | 10 ++++++---- kernel/model/sync.go | 5 ----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/kernel/model/conf.go b/kernel/model/conf.go index e0c57b9f6..b27c07d53 100644 --- a/kernel/model/conf.go +++ b/kernel/model/conf.go @@ -399,10 +399,12 @@ func Close(force bool, execInstallPkg int) (exitCode int) { WaitForWritingFiles() if !force { - syncData(false, true, false) - if 0 != ExitSyncSucc { - exitCode = 1 - return + if Conf.Sync.Enabled && ((IsSubscriber() && conf.ProviderSiYuan == Conf.Sync.Provider) || conf.ProviderSiYuan != Conf.Sync.Provider) { + syncData(false, true, false) + if 0 != ExitSyncSucc { + exitCode = 1 + return + } } } diff --git a/kernel/model/sync.go b/kernel/model/sync.go index bac54db5a..ff2ff2309 100644 --- a/kernel/model/sync.go +++ b/kernel/model/sync.go @@ -91,7 +91,6 @@ func BootSyncData() { } func SyncData(boot, exit, byHand bool) { - util.BroadcastByType("main", "syncing", 0, Conf.Language(81), nil) syncData(boot, exit, byHand) } @@ -161,10 +160,6 @@ func checkSync(boot, exit, byHand bool) bool { return false } - if !cloud.IsValidCloudDirName(Conf.Sync.CloudName) { - return false - } - if util.IsMutexLocked(&syncLock) { logging.LogWarnf("sync is in progress") planSyncAfter(30 * time.Second) From 4916baf31a859f572db3a81b29fe93ff74181c59 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Wed, 25 Jan 2023 22:54:29 +0800 Subject: [PATCH 3/4] =?UTF-8?q?:art:=20=E6=94=B9=E8=BF=9B=E5=86=85?= =?UTF-8?q?=E6=A0=B8=E4=BB=BB=E5=8A=A1=E8=B0=83=E5=BA=A6=E6=9C=BA=E5=88=B6?= =?UTF-8?q?=E6=8F=90=E5=8D=87=E7=A8=B3=E5=AE=9A=E6=80=A7=20https://github.?= =?UTF-8?q?com/siyuan-note/siyuan/issues/7113?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/appearance/langs/en_US.json | 4 ++-- app/appearance/langs/es_ES.json | 4 ++-- app/appearance/langs/fr_FR.json | 4 ++-- app/appearance/langs/zh_CHT.json | 4 ++-- app/appearance/langs/zh_CN.json | 4 ++-- kernel/model/block.go | 3 ++- kernel/model/index.go | 15 --------------- kernel/task/queue.go | 32 ++++++++++++++++++++++++++------ 8 files changed, 38 insertions(+), 32 deletions(-) diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.json index 5f05d325c..6ab437075 100644 --- a/app/appearance/langs/en_US.json +++ b/app/appearance/langs/en_US.json @@ -901,7 +901,7 @@ "12": "Query asset failed [%s]", "13": "Cannot create a file starting with .", "14": "Export failed: %s", - "15": "The content block with ID [%s] was not found, please try again later in the document tree panel menu [Rebuild Index]", + "15": "Content block with id [%s] not found, please try again later", "16": "Please enter the doc name", "17": "The initial synchronization failed at startup. Unpredictable data overwriting may occur if you continue to operate. Please perform a synchronization first", "18": "Get community user account failed", @@ -942,7 +942,7 @@ "53": "Data synchronization has not been enabled", "54": "Indexing references...", "55": "Indexed references of [%d] documents", - "56": "Reindexing, please wait until rebuilding is complete before trying to open the document", + "56": "Reindexing, please wait until rebuilding is complete before trying to open", "57": "Failed to create temp key", "58": "After the index is rebuilt, the interface will be automatically refreshed later...", "59": "Failed to set sync ignore list", diff --git a/app/appearance/langs/es_ES.json b/app/appearance/langs/es_ES.json index 8625038ab..c3798ce80 100644 --- a/app/appearance/langs/es_ES.json +++ b/app/appearance/langs/es_ES.json @@ -901,7 +901,7 @@ "12": "Fallo en la consulta de activos [%s]", "13": "No se puede crear un archivo que empiece por .", "14": "Exportación fallida: %s", - "15": "El bloque de contenido con ID [%s] no se encontró, por favor inténtelo de nuevo más tarde en el menú del panel del árbol del documento [Reconstruir índice]", + "15": "No se encontró el bloque de contenido con id [%s], inténtelo de nuevo más tarde", "16": "Por favor, introduzca el nombre del documento", "17": "La sincronización inicial falló en el arranque. Puede producirse una sobreescritura de datos imprevisible si continúa operando. Por favor, realice primero una sincronización", "18": "Falló la obtención de la cuenta de usuario de la comunidad", @@ -942,7 +942,7 @@ "53": "No se ha habilitado la sincronizacion de datos", "54": "Indexando referencias...", "55": "Referencias indexadas de [%d] documentos", - "56": "Reindexando, espere hasta que se complete la reconstrucción antes de intentar abrir el documento", + "56": "Reindexando, espere hasta que se complete la reconstrucción antes de intentar abrir", "57": "Fallo en la creación de la clave temporal", "58": "Después de reconstruir el índice, la interfaz se actualizará automáticamente más tarde...", "59": " Falló la configuración de sincronización de la lista de ignorados", diff --git a/app/appearance/langs/fr_FR.json b/app/appearance/langs/fr_FR.json index 26e3bdef4..56d33ad79 100644 --- a/app/appearance/langs/fr_FR.json +++ b/app/appearance/langs/fr_FR.json @@ -901,7 +901,7 @@ "12": "Échec de la requête asset [%s]", "13": "Impossible de créer un fichier commençant par .", "14": "L'exportation a échoué : %s", - "15": "Le bloc de contenu avec l'ID [%s] n'a pas été trouvé, veuillez réessayer plus tard dans le menu du panneau de l'arborescence du document [Reconstruire l'index]", + "15": "Bloc de contenu avec l'identifiant [%s] introuvable, veuillez réessayer plus tard", "16": "Veuillez entrer le nom du fichier", "17": "La synchronisation initiale a échoué au démarrage. Un écrasement imprévisible des données peut se produire si vous continuez à fonctionner. Veuillez d'abord effectuer une synchronisation.", "18": "Échec de la récupération du compte utilisateur communautaire", @@ -942,7 +942,7 @@ "53": "La synchronisation des données n'a pas été activée", "54": "Indexation des références...", "55": "Références indexées de [%d] documents", - "56": "Réindexation, veuillez attendre que la reconstruction soit terminée avant d'essayer d'ouvrir le document", + "56": "Réindexation, veuillez attendre que la reconstruction soit terminée avant d'essayer d'ouvrir", "57": "Échec de la création d'une clé temporaire", "58": "Une fois l'index reconstruit, l'interface sera automatiquement rafraîchie ultérieurement...", "59": "Échec de la définition de la liste des ignores de synchronisation", diff --git a/app/appearance/langs/zh_CHT.json b/app/appearance/langs/zh_CHT.json index 89209bc97..e42bacddf 100644 --- a/app/appearance/langs/zh_CHT.json +++ b/app/appearance/langs/zh_CHT.json @@ -901,7 +901,7 @@ "12": "查詢資料檔失敗 [%s]", "13": "無法創建 . 開頭的文件", "14": "匯出失敗:%s", - "15": "未找到 ID 為 [%s] 的內容塊,請在文檔樹面板菜單【重建索引】以後再試", + "15": "未找到 ID 為 [%s] 的內容塊,請稍後再試", "16": "請輸入文檔名", "17": "啟動時初次同步失敗,繼續操作可能會發生無法預測的數據覆蓋,請先執行一次同步", "18": "獲取社區用戶帳號失敗", @@ -942,7 +942,7 @@ "53": "數據同步尚未啟用", "54": "正在索引引用關係...", "55": "已完成索引 [%d] 篇文檔的引用關係", - "56": "正在重建索引,請等重建索引完畢後再嘗試打開該文檔", + "56": "正在重建索引,請等重建索引完畢後再嘗試打開", "57": "創建臨時金鑰失敗", "58": "重建索引完畢,稍後將自動重新整理介面...", "59": "設置同步忽略列表失敗", diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.json index ef6da8ce0..e75df9ae2 100644 --- a/app/appearance/langs/zh_CN.json +++ b/app/appearance/langs/zh_CN.json @@ -901,7 +901,7 @@ "12": "查询资源文件失败 [%s]", "13": "无法创建 . 开头的文件", "14": "导出失败:%s", - "15": "未找到 ID 为 [%s] 的内容块,请在文档树面板菜单 [重建索引] 以后再试", + "15": "未找到 ID 为 [%s] 的内容块,请稍后再试", "16": "请输入文档名", "17": "启动时初次同步失败,继续操作可能会发生无法预测的数据覆盖,请先执行一次同步", "18": "获取社区用户账号失败", @@ -942,7 +942,7 @@ "53": "数据同步尚未启用", "54": "正在索引引用关系...", "55": "已完成索引 [%d] 篇文档的引用关系", - "56": "正在重建索引,请等重建索引完毕后再尝试打开该文档", + "56": "正在重建索引,请等重建索引完毕后再尝试打开", "57": "创建临时密钥失败", "58": "重建索引完毕,稍后将自动刷新界面...", "59": "设置同步忽略列表失败", diff --git a/kernel/model/block.go b/kernel/model/block.go index 650e7f7b4..2ad01bf80 100644 --- a/kernel/model/block.go +++ b/kernel/model/block.go @@ -19,6 +19,7 @@ package model import ( "errors" "fmt" + "github.com/siyuan-note/siyuan/kernel/task" "github.com/88250/lute" "github.com/88250/lute/ast" @@ -393,7 +394,7 @@ func getBlock(id string) (ret *Block, err error) { tree, err := loadTreeByBlockID(id) if nil != err { - if isIndexing() { + if task.ContainIndexTask() { err = ErrIndexing } return diff --git a/kernel/model/index.go b/kernel/model/index.go index e664933b7..2b4477579 100644 --- a/kernel/model/index.go +++ b/kernel/model/index.go @@ -52,27 +52,12 @@ func (box *Box) Index() { task.AppendTask(task.DatabaseIndexRef, IndexRefs) } -var indexing = false - -func isIndexing() (ret bool) { - for i := 0; indexing || i > 7; i++ { - time.Sleep(time.Millisecond * 100) - ret = true - } - return -} - func index(boxID string) { box := Conf.Box(boxID) if nil == box { return } - indexing = true - defer func() { - indexing = false - }() - util.SetBootDetails("Listing files...") files := box.ListFiles("/") boxLen := len(Conf.GetOpenedBoxes()) diff --git a/kernel/task/queue.go b/kernel/task/queue.go index f4741c741..af3ff2f2f 100644 --- a/kernel/task/queue.go +++ b/kernel/task/queue.go @@ -17,6 +17,7 @@ package task import ( + "context" "github.com/siyuan-note/siyuan/kernel/util" "reflect" "sync" @@ -110,6 +111,15 @@ const ( DatabaseIndexEmbedBlock = "task.database.index.embedBlock" // 数据库索引嵌入块 ) +func ContainIndexTask() bool { + for _, task := range taskQueue { + if DatabaseIndex == task.Action || DatabaseIndexFull == task.Action { + return true + } + } + return false +} + func StatusLoop() { for { time.Sleep(5 * time.Second) @@ -138,15 +148,12 @@ func StatusLoop() { } data["tasks"] = items util.PushBackgroundTask(data) - if 0 < len(tasks) { - time.Sleep(5 * time.Second) - } } } func Loop() { for { - time.Sleep(10 * time.Millisecond) + time.Sleep(100 * time.Millisecond) if QueueStatusClosing == taskQueueStatus { clearQueue() break @@ -161,7 +168,7 @@ func Loop() { break } - go execTask(task) + execTask(task) } } @@ -197,5 +204,18 @@ func execTask(task *Task) { } } - task.Handler.Call(args) + ctx, cancel := context.WithTimeout(context.Background(), time.Second*12) + defer cancel() + ch := make(chan bool, 1) + go func() { + task.Handler.Call(args) + ch <- true + }() + + select { + case <-ctx.Done(): + //logging.LogWarnf("task [%s] timeout", task.Action) + case <-ch: + //logging.LogInfof("task [%s] done", task.Action) + } } From d7419e80296e7b46baf7d3698dae8e4248c17a1e Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Wed, 25 Jan 2023 22:58:25 +0800 Subject: [PATCH 4/4] =?UTF-8?q?:art:=20=E6=94=B9=E8=BF=9B=E5=86=85?= =?UTF-8?q?=E6=A0=B8=E4=BB=BB=E5=8A=A1=E8=B0=83=E5=BA=A6=E6=9C=BA=E5=88=B6?= =?UTF-8?q?=E6=8F=90=E5=8D=87=E7=A8=B3=E5=AE=9A=E6=80=A7=20https://github.?= =?UTF-8?q?com/siyuan-note/siyuan/issues/7113?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/block.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/kernel/model/block.go b/kernel/model/block.go index 2ad01bf80..1cc22caba 100644 --- a/kernel/model/block.go +++ b/kernel/model/block.go @@ -19,12 +19,13 @@ package model import ( "errors" "fmt" - "github.com/siyuan-note/siyuan/kernel/task" + "time" "github.com/88250/lute" "github.com/88250/lute/ast" "github.com/88250/lute/parse" "github.com/siyuan-note/siyuan/kernel/sql" + "github.com/siyuan-note/siyuan/kernel/task" "github.com/siyuan-note/siyuan/kernel/treenode" "github.com/siyuan-note/siyuan/kernel/util" ) @@ -396,8 +397,14 @@ func getBlock(id string) (ret *Block, err error) { if nil != err { if task.ContainIndexTask() { err = ErrIndexing + return + } + + time.Sleep(1 * time.Second) + tree, err = loadTreeByBlockID(id) + if nil != err { + return } - return } node := treenode.GetNodeInTree(tree, id)