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)))
}