From 9542b4dcee44ee100e2d8968fc7c40ac5a79d93d Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Thu, 12 Jan 2023 22:11:11 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E9=87=8D=E5=BB=BA=E7=B4=A2=E5=BC=95?= =?UTF-8?q?=E6=97=B6=E4=B8=8D=E8=BF=9B=E8=A1=8C=E6=95=B0=E6=8D=AE=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/transaction.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/kernel/model/transaction.go b/kernel/model/transaction.go index c246510da..ce90b5177 100644 --- a/kernel/model/transaction.go +++ b/kernel/model/transaction.go @@ -20,6 +20,7 @@ import ( "bytes" "errors" "fmt" + "io" "os" "path" "path/filepath" @@ -1246,6 +1247,10 @@ func autoFixIndex() { boxPath := filepath.Join(util.DataDir, box.ID) var paths []string filepath.Walk(boxPath, func(path string, info os.FileInfo, err error) error { + if isFullReindexing { + return io.EOF + } + if !info.IsDir() && filepath.Ext(path) == ".sy" { p := path[len(boxPath):] p = filepath.ToSlash(p) @@ -1258,11 +1263,19 @@ func autoFixIndex() { redundantPaths := treenode.GetRedundantPaths(box.ID, paths) for _, p := range redundantPaths { + if isFullReindexing { + break + } + treenode.RemoveBlockTreesByPath(p) } missingPaths := treenode.GetNotExistPaths(box.ID, paths) for i, p := range missingPaths { + if isFullReindexing { + break + } + reindexTreeByPath(box.ID, p, i, size) } } @@ -1307,6 +1320,10 @@ func autoFixIndex() { duplicatedRootIDs := sql.GetDuplicatedRootIDs() size := len(duplicatedRootIDs) for i, rootID := range duplicatedRootIDs { + if isFullReindexing { + break + } + root := sql.GetBlock(rootID) if nil == root { continue @@ -1321,6 +1338,10 @@ func autoFixIndex() { } func reindexTreeByPath(box, p string, i, size int) { + if isFullReindexing { + return + } + tree, err := LoadTree(box, p) if nil != err { return @@ -1330,6 +1351,10 @@ func reindexTreeByPath(box, p string, i, size int) { } func reindexTree(rootID string, i, size int) { + if isFullReindexing { + return + } + root := treenode.GetBlockTree(rootID) if nil == root { logging.LogWarnf("root block not found", rootID)