aboutsummaryrefslogtreecommitdiffhomepage
path: root/resources
diff options
context:
space:
mode:
Diffstat (limited to 'resources')
-rw-r--r--resources/image.go2
-rw-r--r--resources/resource.go13
2 files changed, 8 insertions, 7 deletions
diff --git a/resources/image.go b/resources/image.go
index 188f49624..56f0981f2 100644
--- a/resources/image.go
+++ b/resources/image.go
@@ -493,7 +493,7 @@ func (i *imageResource) relTargetPathFromConfig(conf images.ImageConfig) interna
}
h := i.hash()
- idStr := fmt.Sprintf("_hu%s_%d", h, i.size())
+ idStr := fmt.Sprintf("_hu%d_%d", h, i.size())
// Do not change for no good reason.
const md5Threshold = 100
diff --git a/resources/resource.go b/resources/resource.go
index 19270307e..cc7008e5a 100644
--- a/resources/resource.go
+++ b/resources/resource.go
@@ -26,6 +26,7 @@ import (
"github.com/gohugoio/hugo/identity"
"github.com/gohugoio/hugo/resources/internal"
+ "github.com/gohugoio/hugo/common/hashing"
"github.com/gohugoio/hugo/common/herrors"
"github.com/gohugoio/hugo/common/paths"
@@ -307,7 +308,7 @@ type fileInfo interface {
}
type hashProvider interface {
- hash() string
+ hash() uint64
}
var _ resource.StaleInfo = (*StaleValue[any])(nil)
@@ -403,7 +404,7 @@ func (l *genericResource) size() int64 {
return l.h.size
}
-func (l *genericResource) hash() string {
+func (l *genericResource) hash() uint64 {
if err := l.h.init(l); err != nil {
panic(err)
}
@@ -628,7 +629,7 @@ type targetPather interface {
}
type resourceHash struct {
- value string
+ value uint64
size int64
initOnce sync.Once
}
@@ -636,7 +637,7 @@ type resourceHash struct {
func (r *resourceHash) init(l hugio.ReadSeekCloserProvider) error {
var initErr error
r.initOnce.Do(func() {
- var hash string
+ var hash uint64
var size int64
f, err := l.ReadSeekCloser()
if err != nil {
@@ -656,6 +657,6 @@ func (r *resourceHash) init(l hugio.ReadSeekCloserProvider) error {
return initErr
}
-func hashImage(r io.ReadSeeker) (string, int64, error) {
- return helpers.MD5FromReaderFast(r)
+func hashImage(r io.ReadSeeker) (uint64, int64, error) {
+ return hashing.XXHashFromReader(r)
}