Skip to content

Commit

Permalink
fix(thumbnails): don't re-create thumbnails if they already exist
Browse files Browse the repository at this point in the history
A previous cleanup introduced a bug which caused thumbnails to be
re-created even if we already had a matching thumbnail in the storage.
  • Loading branch information
rhafer committed Oct 7, 2024
1 parent 9ac5450 commit 11d3057
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/fix-use-existing-thumbnails.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Avoid re-creating thumbnails

We fixed a bug that caused the system to re-create thumbnails for images, even
if a thumbnail already existed in the cache.

https://github.com/owncloud/ocis/pull/1xxxx
13 changes: 11 additions & 2 deletions services/thumbnails/pkg/service/grpc/v0/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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())
}
Expand Down

0 comments on commit 11d3057

Please sign in to comment.