Add debug logs

This commit is contained in:
kolaente 2020-08-02 15:17:52 +02:00
parent f85085271f
commit b379016d1d
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 6 additions and 0 deletions

View File

@ -19,6 +19,7 @@ package upload
import (
"bytes"
"code.vikunja.io/api/pkg/files"
"code.vikunja.io/api/pkg/log"
"code.vikunja.io/api/pkg/user"
"github.com/disintegration/imaging"
"image"
@ -46,15 +47,20 @@ func (p *Provider) GetAvatar(u *user.User, size int64) (avatar []byte, mimeType
a, cached := resizedCache[u.ID]
if cached {
if a != nil && a[size] != nil {
log.Debugf("Serving uploaded avatar for user %d and size %d from cache.", u.ID, size)
return a[size], "", nil
}
// This means we have a map for the user, but nothing in it.
if a == nil {
resizedCache[u.ID] = make(map[int64][]byte)
}
} else {
// Nothing ever cached for this user so we need to create the size map to avoid panics
resizedCache[u.ID] = make(map[int64][]byte)
}
log.Debugf("Uploaded avatar for user %d and size %d not cached, resizing and caching.", u.ID, size)
// If we get this far, the avatar is either not cached at all or not in this size
f := &files.File{ID: u.AvatarFileID}
if err := f.LoadFileByID(); err != nil {