Skip to content

Commit 0b53c48

Browse files
committed
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.
1 parent 86fa6a9 commit 0b53c48

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Bugfix: Avoid re-creating thumbnails
2+
3+
We fixed a bug that caused the system to re-create thumbnails for images, even
4+
if a thumbnail already existed in the cache.
5+
6+
https://github.com/owncloud/ocis/pull/10251

services/thumbnails/pkg/service/grpc/v0/service.go

+11-2
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,12 @@ func (g Thumbnail) handleCS3Source(ctx context.Context, req *thumbnailssvc.GetTh
145145
}
146146

147147
key, tr, err := g.checkThumbnail(req, sRes)
148-
if err != nil {
148+
switch {
149+
case err != nil:
149150
return "", err
151+
case key != "":
152+
// we have matching thumbnail already, use that
153+
return key, nil
150154
}
151155

152156
ctx = imgsource.ContextSetAuthorization(ctx, src.GetAuthorization())
@@ -220,9 +224,14 @@ func (g Thumbnail) handleWebdavSource(ctx context.Context, req *thumbnailssvc.Ge
220224
}
221225

222226
key, tr, err := g.checkThumbnail(req, sRes)
223-
if err != nil {
227+
switch {
228+
case err != nil:
224229
return "", err
230+
case key != "":
231+
// we have matching thumbnail already, use that
232+
return key, nil
225233
}
234+
226235
if src.GetWebdavAuthorization() != "" {
227236
ctx = imgsource.ContextSetAuthorization(ctx, src.GetWebdavAuthorization())
228237
}

0 commit comments

Comments
 (0)