Add logging if downloading an image from unsplash fails

This commit is contained in:
kolaente 2020-05-29 22:11:49 +02:00
parent 54b18b3c59
commit 42ddee8d6f
Signed by untrusted user: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 8 additions and 0 deletions

View File

@ -17,6 +17,7 @@
package unsplash
import (
"bytes"
"code.vikunja.io/api/pkg/config"
"code.vikunja.io/api/pkg/files"
"code.vikunja.io/api/pkg/log"
@ -200,6 +201,13 @@ func (p *Provider) Set(image *background.Image, list *models.List, auth web.Auth
}
defer resp.Body.Close()
if resp.StatusCode > 399 {
b := bytes.Buffer{}
_, _ = b.ReadFrom(resp.Body)
log.Errorf("Error getting unsplash photo %s: Request failed with status %d, message was %s", photo.ID, resp.StatusCode, b.String())
return
}
log.Debugf("Downloaded Unsplash Photo %s", image.ID)
// Save it as a file in vikunja