Added subsonic.folderbrowsing option, and removed debugging

Signed-off-by: Patrik Wallström <pawal@amplitut.de>
This commit is contained in:
Patrik Wallström 2026-03-15 02:31:26 +01:00
parent 501cfce841
commit bc2cb3ab4d
4 changed files with 12 additions and 3 deletions

View File

@ -163,6 +163,7 @@ type subsonicOptions struct {
ArtistParticipations bool
DefaultReportRealPath bool
EnableAverageRating bool
FolderBrowsing bool
LegacyClients string
MinimalClients string
}
@ -710,6 +711,7 @@ func setViperDefaults() {
viper.SetDefault("subsonic.artistparticipations", false)
viper.SetDefault("subsonic.defaultreportrealpath", false)
viper.SetDefault("subsonic.enableaveragerating", true)
viper.SetDefault("subsonic.folderbrowsing", true)
viper.SetDefault("subsonic.legacyclients", "DSub")
viper.SetDefault("subsonic.minimalclients", "SubMusic")
viper.SetDefault("agents", "deezer,lastfm,spotify")

View File

@ -172,7 +172,7 @@ func (p *phaseFolders) producer() ppl.Producer[*folderEntry] {
// Check if folder is outdated
if folder.isOutdated() {
if !p.state.fullScan {
if folder.hasNoFiles() && folder.isNew() {
if folder.hasNoFiles() && folder.isNew() && folder.numSubFolders == 0 {
log.Trace(p.ctx, "Scanner: Skipping new folder with no files", "folder", folder.path, "lib", job.lib.Name)
continue
}

View File

@ -144,13 +144,19 @@ func (api *Router) getFolderIndex(ctx context.Context, musicFolderIds []int, ifM
return res, nil
}
// Filter accessible libraries down to the requested ones
// Fetch all libraries from the database; user.Libraries in context may be
// empty for admin users (not in user_library table), so we can't rely on it.
allLibraries, err := api.ds.Library(ctx).GetAll()
if err != nil {
log.Error(ctx, "Error retrieving libraries for folder index", err)
return nil, err
}
libIdSet := make(map[int]bool, len(musicFolderIds))
for _, id := range musicFolderIds {
libIdSet[id] = true
}
var libraries []model.Library
for _, lib := range getUserAccessibleLibraries(ctx) {
for _, lib := range allLibraries {
if len(libIdSet) == 0 || libIdSet[lib.ID] {
libraries = append(libraries, lib)
}

View File

@ -195,6 +195,7 @@ var _ = Describe("Browsing", func() {
BeforeEach(func() {
lib1 = model.Library{ID: 1, Name: "Test Library 1", Path: "/music/library1"}
ds.Library(ctx).(*tests.MockLibraryRepo).SetData(model.Libraries{lib1})
})
It("should return error when musicFolderId is not accessible", func() {