mirror of
https://github.com/navidrome/navidrome.git
synced 2026-05-03 06:51:16 +00:00
Add Subsonic.FolderBrowsing config flag to gate getIndexes behavior
Signed-off-by: Patrik Wallström <pawal@amplitut.de>
This commit is contained in:
parent
235632f3e5
commit
501cfce841
@ -107,7 +107,12 @@ func (api *Router) GetIndexes(r *http.Request) (*responses.Subsonic, error) {
|
||||
}
|
||||
ifModifiedSince := p.TimeOr("ifModifiedSince", time.Time{})
|
||||
|
||||
res, err := api.getFolderIndex(r.Context(), musicFolderIds, ifModifiedSince)
|
||||
var res *responses.Indexes
|
||||
if conf.Server.Subsonic.FolderBrowsing {
|
||||
res, err = api.getFolderIndex(r.Context(), musicFolderIds, ifModifiedSince)
|
||||
} else {
|
||||
res, err = api.getArtistIndex(r, musicFolderIds, ifModifiedSince)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"net/http/httptest"
|
||||
|
||||
"github.com/navidrome/navidrome/conf"
|
||||
"github.com/navidrome/navidrome/core/auth"
|
||||
"github.com/navidrome/navidrome/model"
|
||||
"github.com/navidrome/navidrome/model/request"
|
||||
@ -262,6 +263,26 @@ var _ = Describe("Browsing", func() {
|
||||
Expect(response.Indexes.Index[0].Name).To(Equal("#"))
|
||||
Expect(response.Indexes.Index[0].Artists[0].Id).To(Equal("f-90s"))
|
||||
})
|
||||
|
||||
It("falls back to artist-based index when FolderBrowsing is disabled", func() {
|
||||
conf.Server.Subsonic.FolderBrowsing = false
|
||||
DeferCleanup(func() { conf.Server.Subsonic.FolderBrowsing = true })
|
||||
|
||||
ctx = contextWithUser(ctx, "user-id", 1)
|
||||
ds.Artist(ctx).(*tests.MockArtistRepo).SetData(model.Artists{
|
||||
{ID: "a-1", Name: "Kraftwerk"},
|
||||
})
|
||||
|
||||
r := httptest.NewRequest("GET", "/rest/getIndexes", nil)
|
||||
r = r.WithContext(ctx)
|
||||
|
||||
response, err := api.GetIndexes(r)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(response.Indexes).ToNot(BeNil())
|
||||
// Artist-based index returns artist entries, not folder entries
|
||||
Expect(response.Indexes.Index).ToNot(BeEmpty())
|
||||
Expect(response.Indexes.Index[0].Artists[0].Id).To(Equal("a-1"))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("GetArtists", func() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user