diff --git a/cmd/root.go b/cmd/root.go index dbeef0f6b..50c33a09c 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -10,6 +10,7 @@ import ( "github.com/navidrome/navidrome/consts" "github.com/navidrome/navidrome/db" "github.com/navidrome/navidrome/log" + "github.com/navidrome/navidrome/resources" "github.com/navidrome/navidrome/scheduler" "github.com/oklog/run" "github.com/spf13/cobra" @@ -45,7 +46,7 @@ func Execute() { func preRun() { if !noBanner { - println(consts.Banner()) + println(resources.Banner()) } conf.Load() } diff --git a/consts/consts.go b/consts/consts.go index 57cd36b03..0471cf7f5 100644 --- a/consts/consts.go +++ b/consts/consts.go @@ -44,7 +44,7 @@ const ( I18nFolder = "i18n" SkipScanFile = ".ndignore" - PlaceholderAlbumArt = "navidrome-600x600.png" + PlaceholderAlbumArt = "placeholder.png" PlaceholderAvatar = "logo-192x192.png" DefaultHttpClientTimeOut = 10 * time.Second diff --git a/consts/banner.go b/resources/banner.go similarity index 61% rename from consts/banner.go rename to resources/banner.go index 296dd8f48..a71830855 100644 --- a/consts/banner.go +++ b/resources/banner.go @@ -1,19 +1,19 @@ -package consts +package resources import ( "fmt" "strings" "unicode" - "github.com/navidrome/navidrome/resources" + "github.com/navidrome/navidrome/consts" ) func loadBanner() string { - data, _ := resources.Asset("banner.txt") + data, _ := Asset("banner.txt") return strings.TrimRightFunc(string(data), unicode.IsSpace) } func Banner() string { - version := "Version: " + Version() + version := "Version: " + consts.Version() return fmt.Sprintf("%s\n%52s\n", loadBanner(), version) } diff --git a/resources/embed.go b/resources/embed.go index 4228d5522..28517ccca 100644 --- a/resources/embed.go +++ b/resources/embed.go @@ -3,10 +3,19 @@ package resources import ( "embed" "io" + "io/fs" + "os" + "path" + + "github.com/navidrome/navidrome/conf" + "github.com/navidrome/navidrome/utils" ) -//go:embed * -var FS embed.FS +var ( + //go:embed * + fsys embed.FS + FS fs.FS +) func Asset(path string) ([]byte, error) { f, err := FS.Open(path) @@ -15,3 +24,10 @@ func Asset(path string) ([]byte, error) { } return io.ReadAll(f) } + +func init() { + FS = utils.MergeFS{ + Base: fsys, + Overlay: os.DirFS(path.Join(conf.Server.DataFolder, "resources")), + } +} diff --git a/resources/navidrome-600x600.png b/resources/placeholder.png similarity index 100% rename from resources/navidrome-600x600.png rename to resources/placeholder.png diff --git a/server/nativeapi/translations.go b/server/nativeapi/translations.go index 5fb93b8eb..aa38e558a 100644 --- a/server/nativeapi/translations.go +++ b/server/nativeapi/translations.go @@ -6,17 +6,14 @@ import ( "encoding/json" "io" "io/fs" - "os" "path" "strings" "sync" "github.com/deluan/rest" - "github.com/navidrome/navidrome/conf" "github.com/navidrome/navidrome/consts" "github.com/navidrome/navidrome/log" "github.com/navidrome/navidrome/resources" - "github.com/navidrome/navidrome/utils" ) type translation struct { @@ -31,11 +28,7 @@ var ( ) func newTranslationRepository(context.Context) rest.Repository { - dir := utils.MergeFS{ - Base: resources.FS, - Overlay: os.DirFS(path.Join(conf.Server.DataFolder, "resources")), - } - if err := loadTranslations(dir); err != nil { + if err := loadTranslations(resources.FS); err != nil { log.Error("Error loading translation files", err) } return &translationRepository{} @@ -50,13 +43,13 @@ func (r *translationRepository) Read(id string) (interface{}, error) { return nil, rest.ErrNotFound } -// Simple Count implementation. Does not support any `options` -func (r *translationRepository) Count(options ...rest.QueryOptions) (int64, error) { +// Count simple implementation, does not support any `options` +func (r *translationRepository) Count(...rest.QueryOptions) (int64, error) { return int64(len(translations)), nil } -// Simple ReadAll implementation, only returns IDs. Does not support any `options` -func (r *translationRepository) ReadAll(options ...rest.QueryOptions) (interface{}, error) { +// ReadAll simple implementation, only returns IDs. Does not support any `options` +func (r *translationRepository) ReadAll(...rest.QueryOptions) (interface{}, error) { var result []translation for _, t := range translations { t.Data = ""