mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-08 08:14:21 +01:00
🎨 Improve data indexing to reduce disk read operations https://github.com/siyuan-note/siyuan/issues/16958
Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
parent
4ac4c2906d
commit
1da1c255f6
1 changed files with 12 additions and 0 deletions
|
|
@ -20,7 +20,10 @@ import (
|
|||
"database/sql"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
|
|
@ -83,6 +86,15 @@ func FlushHistoryQueue() {
|
|||
if err = execHistoryOp(op, tx, context); err != nil {
|
||||
tx.Rollback()
|
||||
logging.LogErrorf("queue operation failed: %s", err)
|
||||
|
||||
if 0 < len(op.histories) {
|
||||
dir := op.histories[0].Path[:strings.Index(op.histories[0].Path, "/")]
|
||||
dirPath := filepath.Join(util.HistoryDir, dir)
|
||||
if removeErr := os.RemoveAll(dirPath); nil != removeErr {
|
||||
logging.LogErrorf("remove corrupted history dir [%s] failed: %s", dirPath, removeErr)
|
||||
}
|
||||
}
|
||||
|
||||
eventbus.Publish(util.EvtSQLHistoryRebuild)
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue