Skip to content

Commit

Permalink
refactor: using listing for thumbnail etag
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Boutour <[email protected]>
  • Loading branch information
ViBiOh committed Sep 3, 2022
1 parent 24025c7 commit 2ca285d
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions pkg/thumbnail/thumbnail.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,20 @@ func (a App) List(w http.ResponseWriter, r *http.Request, item absto.Item, items
}

func (a App) thumbnailHash(ctx context.Context, items []absto.Item) string {
ids := make([]string, len(items))
for index, item := range items {
ids[index] = a.PathForScale(item, SmallSize)
}

thumbnails, err := a.cacheApp.List(ctx, 10, ids...)
if err != nil {
logger.Error("list thumbnail hash: %s", err)
}

hasher := sha.Stream()

for _, item := range items {
if info, err := a.Info(ctx, a.PathForScale(item, SmallSize)); err == nil {
hasher.Write(info)
}
for _, thumbnail := range thumbnails {
hasher.Write(thumbnail)
}

return hasher.Sum()
Expand Down

0 comments on commit 2ca285d

Please sign in to comment.