mirror of
https://github.com/AlistGo/alist.git
synced 2025-04-25 23:04:03 +08:00

* feat: remove index on `SearchNode.Name` As we do not use s% on name column, index there does not work * fix: init index after init data Or on the first run, it will log 'init index error: readObjectStart: expect { or n, but found , error found in #0 byte of ...||..., bigger context ...||...' * fix: match parent more precisely It will match `/a/bc` if we search in `/a/b` originally. But it is not backward compatible by adding a suffix `/` to all the data in parent field
45 lines
870 B
Go
45 lines
870 B
Go
package cmd
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"strconv"
|
|
|
|
"github.com/alist-org/alist/v3/internal/bootstrap"
|
|
"github.com/alist-org/alist/v3/internal/bootstrap/data"
|
|
"github.com/alist-org/alist/v3/pkg/utils"
|
|
log "github.com/sirupsen/logrus"
|
|
)
|
|
|
|
func Init() {
|
|
bootstrap.InitConfig()
|
|
bootstrap.Log()
|
|
bootstrap.InitDB()
|
|
data.InitData()
|
|
bootstrap.InitIndex()
|
|
}
|
|
|
|
var pid = -1
|
|
var pidFile string
|
|
|
|
func initDaemon() {
|
|
ex, err := os.Executable()
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
exPath := filepath.Dir(ex)
|
|
_ = os.MkdirAll(filepath.Join(exPath, "daemon"), 0700)
|
|
pidFile = filepath.Join(exPath, "daemon/pid")
|
|
if utils.Exists(pidFile) {
|
|
bytes, err := os.ReadFile(pidFile)
|
|
if err != nil {
|
|
log.Fatal("failed to read pid file", err)
|
|
}
|
|
id, err := strconv.Atoi(string(bytes))
|
|
if err != nil {
|
|
log.Fatal("failed to parse pid data", err)
|
|
}
|
|
pid = id
|
|
}
|
|
}
|