Fixed a bug when the size was higher then the total number of albums

This commit is contained in:
Deluan 2016-03-13 23:31:24 -04:00
parent 4e0a47d2a6
commit 11e128e08f

View File

@ -4,6 +4,7 @@ import (
"math/rand"
"github.com/deluan/gosonic/domain"
"github.com/deluan/gosonic/utils"
)
// TODO Use Entries instead of Albums
@ -54,7 +55,8 @@ func (g listGenerator) GetRandom(offset int, size int) (*domain.Albums, error) {
if err != nil {
return nil, err
}
perm := rand.Perm(len(*ids))
size = utils.MinInt(size, len(*ids))
perm := rand.Perm(size)
r := make(domain.Albums, size)
for i := 0; i < size; i++ {