mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-04 13:07:36 +03:00
Change duration config types
This commit is contained in:
parent
5021c0fd0c
commit
d2e4cade62
3 changed files with 7 additions and 14 deletions
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/deluan/navidrome/consts"
|
"github.com/deluan/navidrome/consts"
|
||||||
"github.com/deluan/navidrome/log"
|
"github.com/deluan/navidrome/log"
|
||||||
|
@ -15,10 +16,10 @@ type nd struct {
|
||||||
Port int
|
Port int
|
||||||
MusicFolder string
|
MusicFolder string
|
||||||
DataFolder string
|
DataFolder string
|
||||||
ScanInterval string
|
|
||||||
DbPath string
|
DbPath string
|
||||||
LogLevel string
|
LogLevel string
|
||||||
SessionTimeout string
|
ScanInterval time.Duration
|
||||||
|
SessionTimeout time.Duration
|
||||||
BaseURL string
|
BaseURL string
|
||||||
UILoginBackgroundURL string
|
UILoginBackgroundURL string
|
||||||
IgnoredArticles string
|
IgnoredArticles string
|
||||||
|
@ -65,8 +66,8 @@ func SetDefaults() {
|
||||||
viper.SetDefault("datafolder", "./")
|
viper.SetDefault("datafolder", "./")
|
||||||
viper.SetDefault("loglevel", "info")
|
viper.SetDefault("loglevel", "info")
|
||||||
viper.SetDefault("port", 4533)
|
viper.SetDefault("port", 4533)
|
||||||
viper.SetDefault("sessiontimeout", "1h")
|
viper.SetDefault("sessiontimeout", consts.DefaultSessionTimeout)
|
||||||
viper.SetDefault("scaninterval", "1m")
|
viper.SetDefault("scaninterval", time.Minute)
|
||||||
viper.SetDefault("baseurl", "")
|
viper.SetDefault("baseurl", "")
|
||||||
viper.SetDefault("uiloginbackgroundurl", "")
|
viper.SetDefault("uiloginbackgroundurl", "")
|
||||||
viper.SetDefault("enabletranscodingconfig", false)
|
viper.SetDefault("enabletranscodingconfig", false)
|
||||||
|
|
|
@ -44,11 +44,7 @@ func CreateToken(u *model.User) (string, error) {
|
||||||
|
|
||||||
func getSessionTimeOut() time.Duration {
|
func getSessionTimeOut() time.Duration {
|
||||||
if sessionTimeOut == 0 {
|
if sessionTimeOut == 0 {
|
||||||
if to, err := time.ParseDuration(conf.Server.SessionTimeout); err != nil {
|
sessionTimeOut = conf.Server.SessionTimeout
|
||||||
sessionTimeOut = consts.DefaultSessionTimeout
|
|
||||||
} else {
|
|
||||||
sessionTimeOut = to
|
|
||||||
}
|
|
||||||
log.Info("Setting Session Timeout", "value", sessionTimeOut)
|
log.Info("Setting Session Timeout", "value", sessionTimeOut)
|
||||||
}
|
}
|
||||||
return sessionTimeOut
|
return sessionTimeOut
|
||||||
|
|
|
@ -75,11 +75,7 @@ func (a *Server) initRoutes() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Server) initScanner() {
|
func (a *Server) initScanner() {
|
||||||
interval, err := time.ParseDuration(conf.Server.ScanInterval)
|
interval := conf.Server.ScanInterval
|
||||||
if err != nil {
|
|
||||||
log.Error("Invalid interval specification. Using default of 5m", "interval", conf.Server.ScanInterval, err)
|
|
||||||
interval = 5 * time.Minute
|
|
||||||
}
|
|
||||||
if interval == 0 {
|
if interval == 0 {
|
||||||
log.Warn("Scanner is disabled", "interval", conf.Server.ScanInterval)
|
log.Warn("Scanner is disabled", "interval", conf.Server.ScanInterval)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue