feat: customize index max depth

Because some driver's issue may cause infinite loop
This commit is contained in:
Noah Hsu
2023-01-17 17:33:18 +08:00
parent 9c7e451c03
commit 26fe0a7684
7 changed files with 19 additions and 21 deletions

View File

@ -2,7 +2,7 @@ package db
import (
"fmt"
"path"
stdpath "path"
"strings"
"github.com/alist-org/alist/v3/internal/conf"
@ -29,13 +29,13 @@ func BatchCreateSearchNodes(nodes *[]model.SearchNode) error {
return db.CreateInBatches(nodes, 1000).Error
}
func DeleteSearchNodesByParent(prefix string) error {
prefix = utils.FixAndCleanPath(prefix)
err := db.Where(whereInParent(prefix)).Delete(&model.SearchNode{}).Error
func DeleteSearchNodesByParent(path string) error {
path = utils.FixAndCleanPath(path)
err := db.Where(whereInParent(path)).Delete(&model.SearchNode{}).Error
if err != nil {
return err
}
dir, name := path.Split(prefix)
dir, name := stdpath.Split(path)
return db.Where(fmt.Sprintf("%s = ? AND %s = ?",
columnName("parent"), columnName("name")),
dir, name).Delete(&model.SearchNode{}).Error