From 0b53c48bd9654589a92e95ea48c0f1004640841f Mon Sep 17 00:00:00 2001 From: Ralf Haferkamp Date: Mon, 7 Oct 2024 16:51:18 +0200 Subject: [PATCH] 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. --- changelog/unreleased/fix-use-existing-thumbnails.md | 6 ++++++ services/thumbnails/pkg/service/grpc/v0/service.go | 13 +++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 changelog/unreleased/fix-use-existing-thumbnails.md diff --git a/changelog/unreleased/fix-use-existing-thumbnails.md b/changelog/unreleased/fix-use-existing-thumbnails.md new file mode 100644 index 000000000..9f7bfb70d --- /dev/null +++ b/changelog/unreleased/fix-use-existing-thumbnails.md @@ -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/10251 diff --git a/services/thumbnails/pkg/service/grpc/v0/service.go b/services/thumbnails/pkg/service/grpc/v0/service.go index 2279f30c5..e3be60633 100644 --- a/services/thumbnails/pkg/service/grpc/v0/service.go +++ b/services/thumbnails/pkg/service/grpc/v0/service.go @@ -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()) }