Return error when no matching cover is found

When checking stored references to cover images (whether embedded or
external), it's possible that configured patterns do no match, and a
valid error should be returned in those cases.
This commit is contained in:
Alex Palaistras 2020-06-14 11:11:23 +01:00 committed by Deluan Quintão
parent 08cd28af2d
commit d9c991e325
1 changed files with 4 additions and 1 deletions

View File

@ -135,6 +135,7 @@ func (c *cover) getCover(ctx context.Context, path string, size int) (reader io.
}
}()
var data []byte
err = errors.New("no matching cover found")
for _, p := range strings.Split(conf.Server.CoverArtPriority, ",") {
pat := strings.ToLower(strings.TrimSpace(p))
if pat == "embedded" {
@ -147,7 +148,9 @@ func (c *cover) getCover(ctx context.Context, path string, size int) (reader io.
}
}
if err == nil && size > 0 {
if err != nil {
return
} else if size > 0 {
data, err = resizeImage(bytes.NewReader(data), size)
}