mirror of
https://github.com/AlistGo/alist.git
synced 2025-09-15 12:58:42 +08:00
Some checks failed
beta release / Beta Release Changelog (1.21, ubuntu-latest) (push) Has been cancelled
build / Build (ubuntu-latest, android-arm64) (push) Has been cancelled
build / Build (ubuntu-latest, darwin-amd64) (push) Has been cancelled
build / Build (ubuntu-latest, darwin-arm64) (push) Has been cancelled
build / Build (ubuntu-latest, linux-amd64-musl) (push) Has been cancelled
build / Build (ubuntu-latest, linux-arm64-musl) (push) Has been cancelled
build / Build (ubuntu-latest, windows-amd64) (push) Has been cancelled
build / Build (ubuntu-latest, windows-arm64) (push) Has been cancelled
release_docker / Build Binaries for Docker Release (push) Has been cancelled
beta release / Beta Release (md5, !(*musl*|*windows-arm64*|*android*|*freebsd*)) (push) Has been cancelled
beta release / Beta Release (md5-android, android-*) (push) Has been cancelled
beta release / Beta Release (md5-freebsd, freebsd-*) (push) Has been cancelled
beta release / Beta Release (md5-linux-musl, linux-!(arm*)-musl*) (push) Has been cancelled
beta release / Beta Release (md5-linux-musl-arm, linux-arm*-musl*) (push) Has been cancelled
beta release / Beta Release (md5-windows-arm64, windows-arm64) (push) Has been cancelled
beta release / Beta Release Desktop (push) Has been cancelled
release_docker / Release Docker image (, latest, ) (push) Has been cancelled
release_docker / Release Docker image (INSTALL_ARIA2=true, aria2, suffix=-aria2,onlatest=true) (push) Has been cancelled
release_docker / Release Docker image (INSTALL_FFMPEG=true
INSTALL_ARIA2=true
, aio, suffix=-aio,onlatest=true) (push) Has been cancelled
release_docker / Release Docker image (INSTALL_FFMPEG=true, ffmpeg, suffix=-ffmpeg,onlatest=true) (push) Has been cancelled
- Add new imports: `database/sql`, `encoding/json`, and `conf` package in `convert_role.go`. - Simplify permission entry initialization by removing redundant struct formatting. - Update error logging messages for better clarity. - Replace `op.GetUsers` with direct database access for fetching user roles. - Implement role update logic using `rawDb` and handle legacy int role conversion. - Count the number of users whose roles are updated and log completion. - Introduce `IsLegacyRoleDetected` function to check for legacy role formats. - Modify `cmd/common.go` to invoke role conversion if legacy format is detected.
59 lines
1.2 KiB
Go
59 lines
1.2 KiB
Go
package cmd
|
|
|
|
import (
|
|
"github.com/alist-org/alist/v3/internal/bootstrap/patch/v3_46_0"
|
|
"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/internal/db"
|
|
"github.com/alist-org/alist/v3/pkg/utils"
|
|
log "github.com/sirupsen/logrus"
|
|
)
|
|
|
|
func Init() {
|
|
bootstrap.InitConfig()
|
|
bootstrap.Log()
|
|
bootstrap.InitDB()
|
|
|
|
if v3_46_0.IsLegacyRoleDetected() {
|
|
utils.Log.Warnf("Detected legacy role format, executing ConvertLegacyRoles patch early...")
|
|
v3_46_0.ConvertLegacyRoles()
|
|
}
|
|
|
|
data.InitData()
|
|
bootstrap.InitStreamLimit()
|
|
bootstrap.InitIndex()
|
|
bootstrap.InitUpgradePatch()
|
|
}
|
|
|
|
func Release() {
|
|
db.Close()
|
|
}
|
|
|
|
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
|
|
}
|
|
}
|