Skip to content

🎧 Your Personal Streaming Service

Only compute version once

Deluan4cf43ed73541
diff --git a/cmd/root.go b/cmd/root.go
index ea8aea661..fb9e3a716 100644
--- a/cmd/root.go
+++ b/cmd/root.go
@@ -32,7 +32,7 @@ Complete documentation is available at https://www.navidrome.org/docs`,
Run: func(cmd *cobra.Command, args []string) {
runNavidrome()
},
- Version: consts.Version(),
+ Version: consts.Version,
}
)
diff --git a/consts/version.go b/consts/version.go
index 2cab0de8f..cde2449ed 100644
--- a/consts/version.go
+++ b/consts/version.go
@@ -11,15 +11,16 @@ var (
gitSha string
)
-// Formats:
+// Version holds the version string, with tag and git sha info.
+// Examples:
// dev
// v0.2.0 (5b84188)
// v0.3.2-SNAPSHOT (715f552)
// master (9ed35cb)
-func Version() string {
+var Version = func() string {
if gitSha == "" {
return "dev"
}
gitTag = strings.TrimPrefix(gitTag, "v")
return fmt.Sprintf("%s (%s)", gitTag, gitSha)
-}
+}()
diff --git a/model/mediafolder.go b/model/mediafolder.go
index cefa0267a..f9bddd3e8 100644
--- a/model/mediafolder.go
+++ b/model/mediafolder.go
@@ -1,11 +1,20 @@
package model
+import (
+ "io/fs"
+ "os"
+)
+
type MediaFolder struct {
ID int32
Name string
Path string
}
+func (f MediaFolder) FS() fs.FS {
+ return os.DirFS(f.Path)
+}
+
type MediaFolders []MediaFolder
type MediaFolderRepository interface {
diff --git a/resources/banner.go b/resources/banner.go
index a71830855..52f3fcd18 100644
--- a/resources/banner.go
+++ b/resources/banner.go
@@ -14,6 +14,6 @@ func loadBanner() string {
}
func Banner() string {
- version := "Version: " + consts.Version()
+ version := "Version: " + consts.Version
return fmt.Sprintf("%s\n%52s\n", loadBanner(), version)
}
diff --git a/server/events/sse.go b/server/events/sse.go
index c6b0ea29e..910f2ac2d 100644
--- a/server/events/sse.go
+++ b/server/events/sse.go
@@ -212,7 +212,7 @@ func (b *broker) listen() {
// Send a serverStart event to new client
msg := b.prepareMessage(context.Background(),
- &ServerStart{StartTime: consts.ServerStart, Version: consts.Version()})
+ &ServerStart{StartTime: consts.ServerStart, Version: consts.Version})
c.diode.put(msg)
case c := <-b.unsubscribing:
diff --git a/server/serve_index.go b/server/serve_index.go
index 399dde1ee..430755a24 100644
--- a/server/serve_index.go
+++ b/server/serve_index.go
@@ -27,7 +27,7 @@ func serveIndex(ds model.DataStore, fs fs.FS) http.HandlerFunc {
return
}
appConfig := map[string]interface{}{
- "version": consts.Version(),
+ "version": consts.Version,
"firstTime": firstTime,
"variousArtistsId": consts.VariousArtistsID,
"baseURL": utils.SanitizeText(strings.TrimSuffix(conf.Server.BaseURL, "/")),
@@ -63,7 +63,7 @@ func serveIndex(ds model.DataStore, fs fs.FS) http.HandlerFunc {
}
log.Debug("UI configuration", "appConfig", appConfig)
- version := consts.Version()
+ version := consts.Version
if version != "dev" {
version = "v" + version
}
diff --git a/server/serve_index_test.go b/server/serve_index_test.go
index ab88b71d9..bb9174612 100644
--- a/server/serve_index_test.go
+++ b/server/serve_index_test.go
@@ -188,7 +188,7 @@ var _ = Describe("serveIndex", func() {
serveIndex(ds, fs)(w, r)
config := extractAppConfig(w.Body.String())
- Expect(config).To(HaveKeyWithValue("version", consts.Version()))
+ Expect(config).To(HaveKeyWithValue("version", consts.Version))
})
It("sets the losslessFormats", func() {
diff --git a/server/subsonic/helpers.go b/server/subsonic/helpers.go
index a1b9e2ff9..63fd94962 100644
--- a/server/subsonic/helpers.go
+++ b/server/subsonic/helpers.go
@@ -15,7 +15,7 @@ import (
)
func newResponse() *responses.Subsonic {
- return &responses.Subsonic{Status: "ok", Version: Version, Type: consts.AppName, ServerVersion: consts.Version()}
+ return &responses.Subsonic{Status: "ok", Version: Version, Type: consts.AppName, ServerVersion: consts.Version}
}
func requiredParamString(r *http.Request, param string) (string, error) {