This commit is contained in:
Daniel 2023-06-09 13:02:21 +08:00
parent eb941b36e4
commit 073af9a310
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
9 changed files with 16 additions and 8 deletions

View file

@ -96,12 +96,7 @@ func reindexHistory(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
err := model.ReindexHistory()
if nil != err {
ret.Code = -1
ret.Msg = err.Error()
return
}
model.ReindexHistory()
}
func getNotebookHistory(c *gin.Context) {

View file

@ -564,7 +564,12 @@ func getHistoryDir(suffix string, t time.Time) (ret string, err error) {
return
}
func ReindexHistory() (err error) {
func ReindexHistory() {
task.AppendTask(task.HistoryDatabaseIndexFull, fullReindexHistory)
return
}
func fullReindexHistory() {
historyDirs, err := os.ReadDir(util.HistoryDir)
if nil != err {
logging.LogErrorf("read history dir [%s] failed: %s", util.HistoryDir, err)

View file

@ -83,7 +83,8 @@ func FlushHistoryQueue() {
if err = execHistoryOp(op, tx, context); nil != err {
tx.Rollback()
logging.LogErrorf("queue operation failed: %s", err)
continue
util.PushMsg("History database index failed, please try to manually rebuild it in [Data history - File history]", 5000)
return
}
if err = commitHistoryTx(tx); nil != err {

View file

@ -90,6 +90,7 @@ const (
DatabaseIndexFix = "task.database.index.fix" // 数据库索引订正
OCRImage = "task.ocr.image" // 图片 OCR 提取文本
HistoryGenerateDoc = "task.history.generateDoc" // 生成文件历史
HistoryDatabaseIndexFull = "task.history.database.index.full" // 历史数据库重建索引
HistoryDatabaseIndexCommit = "task.history.database.index.commit" // 历史数据库索引提交
DatabaseIndexEmbedBlock = "task.database.index.embedBlock" // 数据库索引嵌入块
ReloadUI = "task.reload.ui" // 重载 UI
@ -103,6 +104,7 @@ var uniqueActions = []string{
DatabaseIndexCommit,
OCRImage,
HistoryGenerateDoc,
HistoryDatabaseIndexFull,
HistoryDatabaseIndexCommit,
DatabaseIndexEmbedBlock,
}