From 7bd973deca60b49bd5baea74570e9a7dd3d86b60 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Sun, 8 Jan 2023 23:23:17 +0800 Subject: [PATCH 01/13] =?UTF-8?q?:art:=20=E8=87=AA=E5=8A=A8=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E6=95=B0=E6=8D=AE=E5=BA=93=E7=B4=A2=E5=BC=95=20https:?= =?UTF-8?q?//github.com/siyuan-note/siyuan/issues/7016?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/transaction.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/kernel/model/transaction.go b/kernel/model/transaction.go index 727ca49b4..26a88d569 100644 --- a/kernel/model/transaction.go +++ b/kernel/model/transaction.go @@ -1227,7 +1227,16 @@ func AutoFixIndex() { } } +var autoFixLock = sync.Mutex{} + func autoFixIndex() { + if util.IsMutexLocked(&autoFixLock) { + return + } + + autoFixLock.Lock() + defer autoFixLock.Unlock() + rootUpdated := treenode.GetRootUpdated() for rootID, updated := range rootUpdated { root := sql.GetBlock(rootID) From c1c6f435b6ad613f2ced40408181483a8a17b8aa Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Sun, 8 Jan 2023 23:40:32 +0800 Subject: [PATCH 02/13] =?UTF-8?q?:art:=20=E8=87=AA=E5=8A=A8=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E6=95=B0=E6=8D=AE=E5=BA=93=E7=B4=A2=E5=BC=95=20https:?= =?UTF-8?q?//github.com/siyuan-note/siyuan/issues/7016?= 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 | 2 +- app/appearance/langs/zh_CN.json | 2 +- kernel/model/box.go | 4 ++++ kernel/model/transaction.go | 23 +++++++++++++++++------ 7 files changed, 26 insertions(+), 11 deletions(-) diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.json index 806a2a4ff..81cf3aab4 100644 --- a/app/appearance/langs/en_US.json +++ b/app/appearance/langs/en_US.json @@ -1051,6 +1051,6 @@ "180": "Search content block does not exist", "181": "The document has been shared to Liandi, click to view", "182": "Sharing document, please wait...", - "183": "Validating index document tree [%s]" + "183": "Validating index document tree [%d/%d %s]" } } diff --git a/app/appearance/langs/es_ES.json b/app/appearance/langs/es_ES.json index 1235f3f9f..057ca5592 100644 --- a/app/appearance/langs/es_ES.json +++ b/app/appearance/langs/es_ES.json @@ -1051,6 +1051,6 @@ "180": "El bloque de contenido de búsqueda no existe", "181": "El documento ha sido compartido con Liandi, haga clic para ver", "182": "Compartiendo documento, por favor espere...", - "183": "Validando el árbol del documento de índice [%s]" + "183": "Validando el árbol del documento de índice [%d/%d %s]" } } diff --git a/app/appearance/langs/fr_FR.json b/app/appearance/langs/fr_FR.json index 899d04cdd..fec071b1e 100644 --- a/app/appearance/langs/fr_FR.json +++ b/app/appearance/langs/fr_FR.json @@ -1051,6 +1051,6 @@ "180": "Le bloc de contenu de recherche n'existe pas", "181": "Le document a été partagé avec Liandi, cliquez pour afficher", "182": "Partage du document, veuillez patienter...", - "183": "Validation de l'arborescence du document d'index [%s]" + "183": "Validation de l'arborescence du document d'index [%d/%d %s]" } } diff --git a/app/appearance/langs/zh_CHT.json b/app/appearance/langs/zh_CHT.json index 035de57ab..c374f55f1 100644 --- a/app/appearance/langs/zh_CHT.json +++ b/app/appearance/langs/zh_CHT.json @@ -1051,6 +1051,6 @@ "180": "不存在符合條件的內容塊", "181": "已分享文檔到鏈滴,點擊查看", "182": "正在分享文檔,請稍等...", - "183": "正在校驗索引文檔樹 [%s]" + "183": "正在校驗索引文檔樹 [%d/%d %s]" } } diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.json index 292099f6c..16a301d47 100644 --- a/app/appearance/langs/zh_CN.json +++ b/app/appearance/langs/zh_CN.json @@ -1051,6 +1051,6 @@ "180": "不存在符合条件的内容块", "181": "已分享文档到链滴,点击查看", "182": "正在分享文档,请稍等...", - "183": "正在校验索引文档树 [%s]" + "183": "正在校验索引文档树 [%d/%d %s]" } } diff --git a/kernel/model/box.go b/kernel/model/box.go index d9cb56573..bd29ac1d1 100644 --- a/kernel/model/box.go +++ b/kernel/model/box.go @@ -523,7 +523,10 @@ func genTreeID(tree *parse.Tree) { return } +var isFullReindexing = false + func FullReindex() { + isFullReindexing = true util.PushEndlessProgress(Conf.Language(35)) WaitForWritingFiles() @@ -542,6 +545,7 @@ func FullReindex() { InitFlashcards() util.PushEndlessProgress(Conf.Language(58)) + isFullReindexing = false go func() { time.Sleep(1 * time.Second) util.ReloadUI() diff --git a/kernel/model/transaction.go b/kernel/model/transaction.go index 26a88d569..053a95e9e 100644 --- a/kernel/model/transaction.go +++ b/kernel/model/transaction.go @@ -1238,17 +1238,28 @@ func autoFixIndex() { defer autoFixLock.Unlock() rootUpdated := treenode.GetRootUpdated() + i := -1 + size := len(rootUpdated) for rootID, updated := range rootUpdated { + if isFullReindexing { + break + } + + i++ + if 0 < i && 0 == i%32 { + treenode.SaveBlockTree(true) + } + root := sql.GetBlock(rootID) if nil == root { logging.LogWarnf("not found tree [%s] in database, reindex it", rootID) - reindexTree(rootID) + reindexTree(rootID, i, size) continue } if "" == updated { // BlockTree 迁移,v2.6.3 之前没有 updated 字段 - reindexTree(rootID) + reindexTree(rootID, i, size) continue } @@ -1256,7 +1267,7 @@ func autoFixIndex() { dbUpdated, _ := time.Parse("20060102150405", root.Updated) if dbUpdated.Before(btUpdated.Add(-1 * time.Minute)) { logging.LogWarnf("tree [%s] is not up to date, reindex it", rootID) - reindexTree(rootID) + reindexTree(rootID, i, size) continue } @@ -1264,13 +1275,13 @@ func autoFixIndex() { if 1 < len(roots) { logging.LogWarnf("exist more than one tree [%s], reindex it", rootID) sql.RemoveTreeQueue(root.Box, rootID) - reindexTree(rootID) + reindexTree(rootID, i, size) continue } } } -func reindexTree(rootID string) { +func reindexTree(rootID string, i, size int) { root := treenode.GetBlockTree(rootID) if nil == root { logging.LogWarnf("root block not found", rootID) @@ -1284,5 +1295,5 @@ func reindexTree(rootID string) { treenode.ReindexBlockTree(tree) sql.UpsertTreeQueue(tree) - util.PushStatusBar(fmt.Sprintf(Conf.Language(183), path.Base(tree.HPath))) + util.PushStatusBar(fmt.Sprintf(Conf.Language(183), i, size, path.Base(tree.HPath))) } From f0750b29cae9d93d6377d6aa2ce6452ebf5b6e83 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Sun, 8 Jan 2023 23:54:43 +0800 Subject: [PATCH 03/13] =?UTF-8?q?:art:=20=E8=87=AA=E5=8A=A8=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E6=95=B0=E6=8D=AE=E5=BA=93=E7=B4=A2=E5=BC=95=20https:?= =?UTF-8?q?//github.com/siyuan-note/siyuan/issues/7016?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/transaction.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kernel/model/transaction.go b/kernel/model/transaction.go index 053a95e9e..2e4dc6ca1 100644 --- a/kernel/model/transaction.go +++ b/kernel/model/transaction.go @@ -1293,6 +1293,12 @@ func reindexTree(rootID string, i, size int) { return } + updated := tree.Root.IALAttr("updated") + if "" == updated { + updated = util.TimeFromID(tree.Root.ID) + tree.Root.SetIALAttr("updated", updated) + writeJSONQueue(tree) + } treenode.ReindexBlockTree(tree) sql.UpsertTreeQueue(tree) util.PushStatusBar(fmt.Sprintf(Conf.Language(183), i, size, path.Base(tree.HPath))) From 3f1cbb2d1d9490c177792e30a54044495d805601 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Sun, 8 Jan 2023 23:55:57 +0800 Subject: [PATCH 04/13] =?UTF-8?q?:art:=20=E8=87=AA=E5=8A=A8=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E6=95=B0=E6=8D=AE=E5=BA=93=E7=B4=A2=E5=BC=95=20https:?= =?UTF-8?q?//github.com/siyuan-note/siyuan/issues/7016?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/transaction.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/model/transaction.go b/kernel/model/transaction.go index 2e4dc6ca1..2b6948a5d 100644 --- a/kernel/model/transaction.go +++ b/kernel/model/transaction.go @@ -1230,7 +1230,7 @@ func AutoFixIndex() { var autoFixLock = sync.Mutex{} func autoFixIndex() { - if util.IsMutexLocked(&autoFixLock) { + if util.IsMutexLocked(&autoFixLock) || isFullReindexing { return } From 248eecb87151d8f047411ad457bbcc9108f54a7d Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Mon, 9 Jan 2023 00:04:49 +0800 Subject: [PATCH 05/13] =?UTF-8?q?:art:=20=E9=87=8D=E5=BB=BA=E7=B4=A2?= =?UTF-8?q?=E5=BC=95=E5=89=8D=E6=B8=85=E7=A9=BA=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E9=98=9F=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/sql/database.go | 1 + kernel/sql/queue.go | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/kernel/sql/database.go b/kernel/sql/database.go index 1f46dd6d5..35c83d946 100644 --- a/kernel/sql/database.go +++ b/kernel/sql/database.go @@ -64,6 +64,7 @@ func InitDatabase(forceRebuild bool) (err error) { util.IncBootProgress(2, "Initializing database...") if forceRebuild { + ClearQueue() WaitForWritingDatabase() } diff --git a/kernel/sql/queue.go b/kernel/sql/queue.go index 02e796089..c9c71cfa2 100644 --- a/kernel/sql/queue.go +++ b/kernel/sql/queue.go @@ -85,6 +85,12 @@ func IsEmptyQueue() bool { return 1 > len(operationQueue) && !util.IsMutexLocked(&txLock) } +func ClearQueue() { + upsertTreeQueueLock.Lock() + defer upsertTreeQueueLock.Unlock() + operationQueue = nil +} + func flushTreeQueue() { ops := mergeUpsertTrees() if 1 > len(ops) { From 559a063c63f088f2f5ebba6d0032794bf9e4e9ae Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Mon, 9 Jan 2023 00:22:18 +0800 Subject: [PATCH 06/13] =?UTF-8?q?:art:=20=E9=87=8D=E5=BB=BA=E7=B4=A2?= =?UTF-8?q?=E5=BC=95=E6=97=B6=E8=A1=A5=E5=85=A8=E6=96=87=E6=A1=A3=E6=A0=91?= =?UTF-8?q?=E7=BC=BA=E5=A4=B1=E7=9A=84=20updated=20=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/index.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kernel/model/index.go b/kernel/model/index.go index 3f0e64b3b..55b7995ba 100644 --- a/kernel/model/index.go +++ b/kernel/model/index.go @@ -78,6 +78,13 @@ func (box *Box) Index(fullRebuildIndex bool) (treeCount int, treeSize int64) { } docIAL := parse.IAL2MapUnEsc(tree.Root.KramdownIAL) + if "" == docIAL["updated"] { + updated := util.TimeFromID(tree.Root.ID) + tree.Root.SetIALAttr("updated", updated) + docIAL["updated"] = updated + writeJSONQueue(tree) + } + cache.PutDocIAL(p, docIAL) util.IncBootProgress(bootProgressPart, fmt.Sprintf(Conf.Language(92), util.ShortPathForBootingDisplay(tree.Path))) From 99e9fd2632da4b140291cd8caab24d06de0fe11a Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Mon, 9 Jan 2023 00:33:01 +0800 Subject: [PATCH 07/13] =?UTF-8?q?:art:=20=E8=87=AA=E5=8A=A8=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E6=95=B0=E6=8D=AE=E5=BA=93=E7=B4=A2=E5=BC=95=20https:?= =?UTF-8?q?//github.com/siyuan-note/siyuan/issues/7016?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/transaction.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/kernel/model/transaction.go b/kernel/model/transaction.go index 2b6948a5d..92c01616c 100644 --- a/kernel/model/transaction.go +++ b/kernel/model/transaction.go @@ -1246,9 +1246,6 @@ func autoFixIndex() { } i++ - if 0 < i && 0 == i%32 { - treenode.SaveBlockTree(true) - } root := sql.GetBlock(rootID) if nil == root { From d7090839e707544bbaa2b30e57f54fe8226d2ea9 Mon Sep 17 00:00:00 2001 From: Andreas <43118918+eulores@users.noreply.github.com> Date: Mon, 9 Jan 2023 02:42:10 +0100 Subject: [PATCH 08/13] Update en_US.json (#7020) The english language file contained a spanish translation. This has been corrected. --- app/appearance/langs/en_US.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.json index 81cf3aab4..bfaf29930 100644 --- a/app/appearance/langs/en_US.json +++ b/app/appearance/langs/en_US.json @@ -181,7 +181,7 @@ "exportPDF3": "Page Scale", "exportPDF4": "Remove assets directory", "exportPDF5": "Keep folded", - "exportPDF6": "Fusionar subdocumentos", + "exportPDF6": "Merge subdocuments", "upload": "Upload", "reminderTip": "The reminder time cannot be less than the current time", "wechatTip": "The content block will be sent to the cloud in clear text, and pushed through the WeChat MP template message when it expires", From c631b64d00337fee2fede2ae559c4dc6c1a61440 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Mon, 9 Jan 2023 10:25:50 +0800 Subject: [PATCH 09/13] =?UTF-8?q?:art:=20=E8=87=AA=E5=8A=A8=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E6=95=B0=E6=8D=AE=E5=BA=93=E7=B4=A2=E5=BC=95=20https:?= =?UTF-8?q?//github.com/siyuan-note/siyuan/issues/7016?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/transaction.go | 29 ++++++++++++++++++----------- kernel/sql/block_query.go | 23 ++++++++++++++++++----- 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/kernel/model/transaction.go b/kernel/model/transaction.go index 92c01616c..6e5e64278 100644 --- a/kernel/model/transaction.go +++ b/kernel/model/transaction.go @@ -1237,18 +1237,21 @@ func autoFixIndex() { autoFixLock.Lock() defer autoFixLock.Unlock() - rootUpdated := treenode.GetRootUpdated() + rootUpdatedMap := treenode.GetRootUpdated() i := -1 - size := len(rootUpdated) - for rootID, updated := range rootUpdated { + size := len(rootUpdatedMap) + for rootID, updated := range rootUpdatedMap { if isFullReindexing { break } i++ - root := sql.GetBlock(rootID) - if nil == root { + rootUpdated, err := sql.GetRootUpdated(rootID) + if nil != err { + continue + } + if "" == rootUpdated { logging.LogWarnf("not found tree [%s] in database, reindex it", rootID) reindexTree(rootID, i, size) continue @@ -1261,20 +1264,24 @@ func autoFixIndex() { } btUpdated, _ := time.Parse("20060102150405", updated) - dbUpdated, _ := time.Parse("20060102150405", root.Updated) + dbUpdated, _ := time.Parse("20060102150405", rootUpdated) if dbUpdated.Before(btUpdated.Add(-1 * time.Minute)) { logging.LogWarnf("tree [%s] is not up to date, reindex it", rootID) reindexTree(rootID, i, size) continue } + } - roots := sql.GetBlockRedundant(rootID) - if 1 < len(roots) { - logging.LogWarnf("exist more than one tree [%s], reindex it", rootID) - sql.RemoveTreeQueue(root.Box, rootID) - reindexTree(rootID, i, size) + duplicatedRootIDs := sql.GetDuplicatedRootIDs() + for _, rootID := range duplicatedRootIDs { + root := sql.GetBlock(rootID) + if nil == root { continue } + + logging.LogWarnf("exist more than one tree [%s], reindex it", rootID) + sql.RemoveTreeQueue(root.Box, rootID) + reindexTree(rootID, i, size) } } diff --git a/kernel/sql/block_query.go b/kernel/sql/block_query.go index 50c811e5f..693bdd8c1 100644 --- a/kernel/sql/block_query.go +++ b/kernel/sql/block_query.go @@ -581,17 +581,30 @@ func GetBlock(id string) (ret *Block) { return } -func GetBlockRedundant(id string) (ret []*Block) { - rows, err := query("SELECT * FROM blocks WHERE id = ?", id) +func GetRootUpdated(rootID string) (ret string, err error) { + rows, err := query("SELECT updated FROM blocks WHERE root_id = ? AND type = 'd'", rootID) if nil != err { logging.LogErrorf("sql query failed: %s", err) return } defer rows.Close() for rows.Next() { - if block := scanBlockRows(rows); nil != block { - ret = append(ret, block) - } + rows.Scan(&ret) + } + return +} + +func GetDuplicatedRootIDs() (ret []string) { + rows, err := query("SELECT DISTINCT root_id FROM blocks GROUP BY id HAVING COUNT(*) > 1") + if nil != err { + logging.LogErrorf("sql query failed: %s", err) + return + } + defer rows.Close() + for rows.Next() { + var id string + rows.Scan(&id) + ret = append(ret, id) } return } From dc112fd56c29186b293adb95a9472a79cff61ab3 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Mon, 9 Jan 2023 10:34:37 +0800 Subject: [PATCH 10/13] =?UTF-8?q?:art:=20=E8=87=AA=E5=8A=A8=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E6=95=B0=E6=8D=AE=E5=BA=93=E7=B4=A2=E5=BC=95=20https:?= =?UTF-8?q?//github.com/siyuan-note/siyuan/issues/7016?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/transaction.go | 57 +++++++++++++++++++------------------ kernel/sql/block_query.go | 10 +++++-- 2 files changed, 36 insertions(+), 31 deletions(-) diff --git a/kernel/model/transaction.go b/kernel/model/transaction.go index 6e5e64278..36608549c 100644 --- a/kernel/model/transaction.go +++ b/kernel/model/transaction.go @@ -1238,42 +1238,43 @@ func autoFixIndex() { defer autoFixLock.Unlock() rootUpdatedMap := treenode.GetRootUpdated() - i := -1 - size := len(rootUpdatedMap) - for rootID, updated := range rootUpdatedMap { - if isFullReindexing { - break - } + dbRootUpdatedMap, err := sql.GetRootUpdated() + if nil == err { + i := -1 + size := len(rootUpdatedMap) + for rootID, updated := range rootUpdatedMap { + if isFullReindexing { + break + } - i++ + i++ - rootUpdated, err := sql.GetRootUpdated(rootID) - if nil != err { - continue - } - if "" == rootUpdated { - logging.LogWarnf("not found tree [%s] in database, reindex it", rootID) - reindexTree(rootID, i, size) - continue - } + rootUpdated := dbRootUpdatedMap[rootID] + if "" == rootUpdated { + logging.LogWarnf("not found tree [%s] in database, reindex it", rootID) + reindexTree(rootID, i, size) + continue + } - if "" == updated { - // BlockTree 迁移,v2.6.3 之前没有 updated 字段 - reindexTree(rootID, i, size) - continue - } + if "" == updated { + // BlockTree 迁移,v2.6.3 之前没有 updated 字段 + reindexTree(rootID, i, size) + continue + } - btUpdated, _ := time.Parse("20060102150405", updated) - dbUpdated, _ := time.Parse("20060102150405", rootUpdated) - if dbUpdated.Before(btUpdated.Add(-1 * time.Minute)) { - logging.LogWarnf("tree [%s] is not up to date, reindex it", rootID) - reindexTree(rootID, i, size) - continue + btUpdated, _ := time.Parse("20060102150405", updated) + dbUpdated, _ := time.Parse("20060102150405", rootUpdated) + if dbUpdated.Before(btUpdated.Add(-1 * time.Minute)) { + logging.LogWarnf("tree [%s] is not up to date, reindex it", rootID) + reindexTree(rootID, i, size) + continue + } } } duplicatedRootIDs := sql.GetDuplicatedRootIDs() - for _, rootID := range duplicatedRootIDs { + size := len(duplicatedRootIDs) + for i, rootID := range duplicatedRootIDs { root := sql.GetBlock(rootID) if nil == root { continue diff --git a/kernel/sql/block_query.go b/kernel/sql/block_query.go index 693bdd8c1..71b5bd8ac 100644 --- a/kernel/sql/block_query.go +++ b/kernel/sql/block_query.go @@ -581,15 +581,19 @@ func GetBlock(id string) (ret *Block) { return } -func GetRootUpdated(rootID string) (ret string, err error) { - rows, err := query("SELECT updated FROM blocks WHERE root_id = ? AND type = 'd'", rootID) +func GetRootUpdated() (ret map[string]string, err error) { + rows, err := query("SELECT root_id, updated FROM blocks WHERE type = 'd'") if nil != err { logging.LogErrorf("sql query failed: %s", err) return } defer rows.Close() + + ret = map[string]string{} for rows.Next() { - rows.Scan(&ret) + var rootID, updated string + rows.Scan(&rootID, &updated) + ret[rootID] = updated } return } From 72dd9192aed3a9dda83ae923668f10b285e3bca4 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Mon, 9 Jan 2023 10:37:56 +0800 Subject: [PATCH 11/13] =?UTF-8?q?:art:=20=E8=87=AA=E5=8A=A8=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E6=95=B0=E6=8D=AE=E5=BA=93=E7=B4=A2=E5=BC=95=20https:?= =?UTF-8?q?//github.com/siyuan-note/siyuan/issues/7016?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/transaction.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/model/transaction.go b/kernel/model/transaction.go index 36608549c..c4e131ca1 100644 --- a/kernel/model/transaction.go +++ b/kernel/model/transaction.go @@ -1264,7 +1264,7 @@ func autoFixIndex() { btUpdated, _ := time.Parse("20060102150405", updated) dbUpdated, _ := time.Parse("20060102150405", rootUpdated) - if dbUpdated.Before(btUpdated.Add(-1 * time.Minute)) { + if dbUpdated.Before(btUpdated.Add(-10 * time.Minute)) { logging.LogWarnf("tree [%s] is not up to date, reindex it", rootID) reindexTree(rootID, i, size) continue From 05f7ef31a7e0d9e5731e45123a4bd35010a058e8 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Mon, 9 Jan 2023 10:41:45 +0800 Subject: [PATCH 12/13] =?UTF-8?q?:art:=20=E8=87=AA=E5=8A=A8=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E6=95=B0=E6=8D=AE=E5=BA=93=E7=B4=A2=E5=BC=95=20https:?= =?UTF-8?q?//github.com/siyuan-note/siyuan/issues/7016?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/transaction.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/model/transaction.go b/kernel/model/transaction.go index c4e131ca1..3a022d774 100644 --- a/kernel/model/transaction.go +++ b/kernel/model/transaction.go @@ -1223,7 +1223,7 @@ func updateRefText(refNode *ast.Node, changedDefNodes map[string]*ast.Node) (cha func AutoFixIndex() { for { autoFixIndex() - time.Sleep(30 * time.Second) + time.Sleep(10 * time.Minute) } } From a19a7aa6ca0ba1c0e26200e1b504d9878bc59fd0 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Mon, 9 Jan 2023 10:46:54 +0800 Subject: [PATCH 13/13] =?UTF-8?q?:art:=20=E8=87=AA=E5=8A=A8=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E6=95=B0=E6=8D=AE=E5=BA=93=E7=B4=A2=E5=BC=95=20https:?= =?UTF-8?q?//github.com/siyuan-note/siyuan/issues/7016?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/transaction.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kernel/model/transaction.go b/kernel/model/transaction.go index 3a022d774..92dc9be46 100644 --- a/kernel/model/transaction.go +++ b/kernel/model/transaction.go @@ -1302,9 +1302,10 @@ func reindexTree(rootID string, i, size int) { if "" == updated { updated = util.TimeFromID(tree.Root.ID) tree.Root.SetIALAttr("updated", updated) - writeJSONQueue(tree) + indexWriteJSONQueue(tree) + } else { + treenode.ReindexBlockTree(tree) + sql.UpsertTreeQueue(tree) } - treenode.ReindexBlockTree(tree) - sql.UpsertTreeQueue(tree) util.PushStatusBar(fmt.Sprintf(Conf.Language(183), i, size, path.Base(tree.HPath))) }