mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-03 04:27:37 +03:00
feat: add conf for data folder, default current folder (not ./data anymore)
This commit is contained in:
parent
828dc8f0f4
commit
f9db80c409
6 changed files with 16 additions and 8 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -14,6 +14,7 @@ navidrome.toml
|
|||
master.zip
|
||||
Jamstash-master
|
||||
testDB
|
||||
navidrome.db
|
||||
*.swp
|
||||
*_gen.go
|
||||
dist
|
||||
|
|
|
@ -44,7 +44,7 @@ COPY --from=gobuilder /tmp/ffmpeg*/ffmpeg /usr/bin/
|
|||
|
||||
VOLUME ["/data", "/music"]
|
||||
ENV ND_MUSICFOLDER /music
|
||||
ENV ND_DBPATH /data/navidrome.db
|
||||
ENV ND_DATAFOLDER /data
|
||||
ENV ND_SCANINTERVAL 1m
|
||||
ENV ND_LOGLEVEL info
|
||||
ENV ND_PORT 4533
|
||||
|
|
|
@ -56,7 +56,7 @@ services:
|
|||
environment:
|
||||
# All options with their default values:
|
||||
ND_MUSICFOLDER: /music
|
||||
ND_DBPATH: /data/navidrome.db
|
||||
ND_DATAFOLDER: /data
|
||||
ND_SCANINTERVAL: 1m
|
||||
ND_LOGLEVEL: info
|
||||
ND_PORT: 4533
|
||||
|
|
|
@ -2,7 +2,9 @@ package conf
|
|||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/deluan/navidrome/consts"
|
||||
"github.com/deluan/navidrome/log"
|
||||
|
@ -12,7 +14,8 @@ import (
|
|||
type nd struct {
|
||||
Port string `default:"4533"`
|
||||
MusicFolder string `default:"./music"`
|
||||
DbPath string `default:"./data/navidrome.db"`
|
||||
DataFolder string `default:"./"`
|
||||
DbPath string
|
||||
LogLevel string `default:"info"`
|
||||
|
||||
IgnoredArticles string `default:"The El La Los Las Le Les Os As O A"`
|
||||
|
@ -30,13 +33,17 @@ type nd struct {
|
|||
|
||||
var Server = &nd{}
|
||||
|
||||
func LoadFromFile(tomlFile string) {
|
||||
m := multiconfig.NewWithPath(tomlFile)
|
||||
func LoadFromFile(confFile string) {
|
||||
m := multiconfig.NewWithPath(confFile)
|
||||
err := m.Load(Server)
|
||||
if err == flag.ErrHelp {
|
||||
os.Exit(1)
|
||||
}
|
||||
log.SetLogLevelString(Server.LogLevel)
|
||||
if Server.DbPath == "" {
|
||||
Server.DbPath = filepath.Join(Server.DataFolder, "navidrome.db")
|
||||
}
|
||||
log.SerLevelString(Server.LogLevel)
|
||||
log.Trace("Loaded configuration", "file", confFile, "config", fmt.Sprintf("%#v", Server))
|
||||
}
|
||||
|
||||
func Load() {
|
||||
|
|
|
@ -35,7 +35,7 @@ func SetLevel(l Level) {
|
|||
logrus.SetLevel(logrus.Level(l))
|
||||
}
|
||||
|
||||
func SetLogLevelString(l string) {
|
||||
func SerLevelString(l string) {
|
||||
envLevel := strings.ToLower(l)
|
||||
var level Level
|
||||
switch envLevel {
|
||||
|
|
|
@ -31,7 +31,7 @@ func New() model.DataStore {
|
|||
if dbPath == ":memory:" {
|
||||
dbPath = "file::memory:?cache=shared"
|
||||
}
|
||||
log.Debug("Opening DB from: "+dbPath, "driver", driver)
|
||||
log.Debug("Opening DataBase", "dbPath", dbPath, "driver", driver)
|
||||
|
||||
err := initORM(dbPath)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue