fix(thumbnails): don't re-create thumbnails if they already exist

A previous cleanup introduced a bug which caused thumbnails to be
re-created even if we already had a matching thumbnail in the storage.
This commit is contained in:
Ralf Haferkamp
2024-10-08 10:37:36 +02:00
committed by Ralf Haferkamp
parent 86fa6a9cde
commit 0b53c48bd9
2 changed files with 17 additions and 2 deletions
@@ -145,8 +145,12 @@ func (g Thumbnail) handleCS3Source(ctx context.Context, req *thumbnailssvc.GetTh
}
key, tr, err := g.checkThumbnail(req, sRes)
if err != nil {
switch {
case err != nil:
return "", err
case key != "":
// we have matching thumbnail already, use that
return key, nil
}
ctx = imgsource.ContextSetAuthorization(ctx, src.GetAuthorization())
@@ -220,9 +224,14 @@ func (g Thumbnail) handleWebdavSource(ctx context.Context, req *thumbnailssvc.Ge
}
key, tr, err := g.checkThumbnail(req, sRes)
if err != nil {
switch {
case err != nil:
return "", err
case key != "":
// we have matching thumbnail already, use that
return key, nil
}
if src.GetWebdavAuthorization() != "" {
ctx = imgsource.ContextSetAuthorization(ctx, src.GetWebdavAuthorization())
}