resources: Re-publish on transformation cache hit

When a resource transformation result was served from cache (same
options as a previous build), the output file was not re-written to
disk. This caused incorrect output when toggling transformation
options (e.g. minify) back to a previously seen value in server mode.

Fixes #14629
This commit is contained in:
Bjørn Erik Pedersen
2026-03-15 11:38:18 +01:00
parent 404ac00001
commit 3c980c072e
10 changed files with 105 additions and 9 deletions
+6
View File
@@ -22,6 +22,7 @@ import (
"strings"
"sync"
"github.com/gohugoio/hugo/common/hmaps"
"github.com/gohugoio/hugo/resources/resource"
"github.com/gohugoio/hugo/cache/dynacache"
@@ -56,6 +57,8 @@ func newResourceCache(rs *Spec, memCache *dynacache.Cache) *ResourceCache {
"/res1/tra",
dynacache.OptionsPartition{ClearWhen: dynacache.ClearOnChange, Weight: 40},
),
cacheResourceTransformationPublished: hmaps.NewMap[string, string](),
}
}
@@ -68,6 +71,9 @@ type ResourceCache struct {
cacheResources *dynacache.Partition[string, resource.Resources]
cacheResourceTransformation *dynacache.Partition[string, *resourceAdapterInner]
// Used in rebuilds. Maps the target path to the last published transformation key.
cacheResourceTransformationPublished *hmaps.Map[string, string]
fileCache *filecache.Cache
}