mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-27 06:00:25 +03:00
resources: Fix 2 image file cache key issues
* Always include the content hash in the cache key for unprocessed images. * Always include the image config hash in the cache key. This is also a major cleanup/simplification of the implementation in this area. Note that this, unfortunately, forces new hashes/filenames for generated images. Fixes #13273 Fixes #13272
This commit is contained in:
parent
8897113666
commit
1f5a15aba0
38 changed files with 342 additions and 233 deletions
|
@ -183,29 +183,33 @@ func (r *Spec) NewResource(rd ResourceSourceDescriptor) (resource.Resource, erro
|
|||
TargetBasePaths: rd.TargetBasePaths,
|
||||
}
|
||||
|
||||
gr := &genericResource{
|
||||
Staler: &AtomicStaler{},
|
||||
h: &resourceHash{},
|
||||
publishInit: &sync.Once{},
|
||||
keyInit: &sync.Once{},
|
||||
paths: rp,
|
||||
spec: r,
|
||||
sd: rd,
|
||||
params: rd.Params,
|
||||
name: rd.NameOriginal,
|
||||
title: rd.Title,
|
||||
isImage := rd.MediaType.MainType == "image"
|
||||
var imgFormat images.Format
|
||||
if isImage {
|
||||
imgFormat, isImage = images.ImageFormatFromMediaSubType(rd.MediaType.SubType)
|
||||
}
|
||||
|
||||
if rd.MediaType.MainType == "image" {
|
||||
imgFormat, ok := images.ImageFormatFromMediaSubType(rd.MediaType.SubType)
|
||||
if ok {
|
||||
ir := &imageResource{
|
||||
Image: images.NewImage(imgFormat, r.imaging, nil, gr),
|
||||
baseResource: gr,
|
||||
}
|
||||
ir.root = ir
|
||||
return newResourceAdapter(gr.spec, rd.LazyPublish, ir), nil
|
||||
gr := &genericResource{
|
||||
Staler: &AtomicStaler{},
|
||||
h: &resourceHash{},
|
||||
publishInit: &sync.Once{},
|
||||
keyInit: &sync.Once{},
|
||||
includeHashInKey: isImage,
|
||||
paths: rp,
|
||||
spec: r,
|
||||
sd: rd,
|
||||
params: rd.Params,
|
||||
name: rd.NameOriginal,
|
||||
title: rd.Title,
|
||||
}
|
||||
|
||||
if isImage {
|
||||
ir := &imageResource{
|
||||
Image: images.NewImage(imgFormat, r.imaging, nil, gr),
|
||||
baseResource: gr,
|
||||
}
|
||||
ir.root = ir
|
||||
return newResourceAdapter(gr.spec, rd.LazyPublish, ir), nil
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue