rename context

This commit is contained in:
David Christofas
2020-03-25 16:56:45 +01:00
parent 39ea10a886
commit 0e2223819d
5 changed files with 35 additions and 35 deletions
+6 -6
View File
@@ -52,36 +52,36 @@ func (g Thumbnail) GetThumbnail(ctx context.Context, req *v0proto.GetRequest, rs
return fmt.Errorf("can't be encoded. filetype %s not supported", req.Filetype.String())
}
r := g.resolutions.ClosestMatch(int(req.Width), int(req.Height))
tCtx := thumbnails.Context{
tr := thumbnails.Request{
Resolution: r,
ImagePath: req.Filepath,
Encoder: encoder,
ETag: req.Etag,
}
thumbnail := g.manager.GetStored(tCtx)
thumbnail := g.manager.GetStored(tr)
if thumbnail != nil {
rsp.Thumbnail = thumbnail
rsp.Mimetype = tCtx.Encoder.MimeType()
rsp.Mimetype = tr.Encoder.MimeType()
return nil
}
auth := req.Authorization
sCtx := context.WithValue(ctx, imgsource.WebDavAuth, auth)
// TODO: clean up error handling
img, err := g.source.Get(sCtx, tCtx.ImagePath)
img, err := g.source.Get(sCtx, tr.ImagePath)
if err != nil {
return err
}
if img == nil {
return fmt.Errorf("could not retrieve image")
}
thumbnail, err = g.manager.Get(tCtx, img)
thumbnail, err = g.manager.Get(tr, img)
if err != nil {
return err
}
rsp.Thumbnail = thumbnail
rsp.Mimetype = tCtx.Encoder.MimeType()
rsp.Mimetype = tr.Encoder.MimeType()
return nil
}