File tree Expand file tree Collapse file tree 1 file changed +20
-15
lines changed
backend/mediaprovider/subsonic Expand file tree Collapse file tree 1 file changed +20
-15
lines changed Original file line number Diff line number Diff line change @@ -41,22 +41,27 @@ func (a *allTracksIterator) Next() *mediaprovider.Track {
4141
4242 // fetch next album
4343 if a .curAlbum == nil || a .curTrackIdx >= len (a .curAlbum .Tracks ) {
44- al := a .albumIter .Next ()
45- if al == nil {
46- a .done = true
47- return nil
48- }
49- alWithTracks , err := a .s .GetAlbum (al .ID )
50- if err != nil {
51- log .Printf ("error fetching album: %s" , err .Error ())
52- }
53- if len (alWithTracks .Tracks ) == 0 {
54- // in the unlikely case of an album with zero tracks,
55- // just call recursively to move to next album
56- return a .Next ()
44+ haveNextAlbum := false
45+ for ! haveNextAlbum && ! a .done {
46+ al := a .albumIter .Next ()
47+ if al == nil {
48+ a .done = true
49+ return nil
50+ }
51+ alWithTracks , err := a .s .GetAlbum (al .ID )
52+ if err != nil || alWithTracks == nil {
53+ log .Printf ("error fetching album: %s" , err .Error ())
54+ continue // try next album
55+ }
56+ haveNextAlbum = true
57+ if len (alWithTracks .Tracks ) == 0 {
58+ // in the unlikely case of an album with zero tracks,
59+ // just call recursively to move to next album
60+ return a .Next ()
61+ }
62+ a .curAlbum = alWithTracks
63+ a .curTrackIdx = 0
5764 }
58- a .curAlbum = alWithTracks
59- a .curTrackIdx = 0
6065 }
6166
6267 tr := a .curAlbum .Tracks [a .curTrackIdx ]
You can’t perform that action at this time.
0 commit comments