mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-18 07:30:12 +01:00
This commit is contained in:
parent
c631b64d00
commit
dc112fd56c
2 changed files with 36 additions and 31 deletions
|
|
@ -1238,6 +1238,8 @@ func autoFixIndex() {
|
|||
defer autoFixLock.Unlock()
|
||||
|
||||
rootUpdatedMap := treenode.GetRootUpdated()
|
||||
dbRootUpdatedMap, err := sql.GetRootUpdated()
|
||||
if nil == err {
|
||||
i := -1
|
||||
size := len(rootUpdatedMap)
|
||||
for rootID, updated := range rootUpdatedMap {
|
||||
|
|
@ -1247,10 +1249,7 @@ func autoFixIndex() {
|
|||
|
||||
i++
|
||||
|
||||
rootUpdated, err := sql.GetRootUpdated(rootID)
|
||||
if nil != err {
|
||||
continue
|
||||
}
|
||||
rootUpdated := dbRootUpdatedMap[rootID]
|
||||
if "" == rootUpdated {
|
||||
logging.LogWarnf("not found tree [%s] in database, reindex it", rootID)
|
||||
reindexTree(rootID, i, size)
|
||||
|
|
@ -1271,9 +1270,11 @@ func autoFixIndex() {
|
|||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
duplicatedRootIDs := sql.GetDuplicatedRootIDs()
|
||||
for _, rootID := range duplicatedRootIDs {
|
||||
size := len(duplicatedRootIDs)
|
||||
for i, rootID := range duplicatedRootIDs {
|
||||
root := sql.GetBlock(rootID)
|
||||
if nil == root {
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue