This commit is contained in:
Liang Ding 2023-01-08 23:40:32 +08:00
parent 7bd973deca
commit c1c6f435b6
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
7 changed files with 26 additions and 11 deletions

View file

@ -1051,6 +1051,6 @@
"180": "Search content block does not exist",
"181": "The document has been shared to Liandi, <a href=\"%s\" target=\"_blank\">click to view</a>",
"182": "Sharing document, please wait...",
"183": "Validating index document tree [%s]"
"183": "Validating index document tree [%d/%d %s]"
}
}

View file

@ -1051,6 +1051,6 @@
"180": "El bloque de contenido de búsqueda no existe",
"181": "El documento ha sido compartido con Liandi, <a href=\"%s\" target=\"_blank\">haga clic para ver</a>",
"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]"
}
}

View file

@ -1051,6 +1051,6 @@
"180": "Le bloc de contenu de recherche n'existe pas",
"181": "Le document a été partagé avec Liandi, <a href=\"%s\" target=\"_blank\">cliquez pour afficher</a>",
"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]"
}
}

View file

@ -1051,6 +1051,6 @@
"180": "不存在符合條件的內容塊",
"181": "已分享文檔到鏈滴,<a href=\"%s\" target=\"_blank\">點擊查看</a>",
"182": "正在分享文檔,請稍等...",
"183": "正在校驗索引文檔樹 [%s]"
"183": "正在校驗索引文檔樹 [%d/%d %s]"
}
}

View file

@ -1051,6 +1051,6 @@
"180": "不存在符合条件的内容块",
"181": "已分享文档到链滴,<a href=\"%s\" target=\"_blank\">点击查看</a>",
"182": "正在分享文档,请稍等...",
"183": "正在校验索引文档树 [%s]"
"183": "正在校验索引文档树 [%d/%d %s]"
}
}

View file

@ -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()

View file

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