aboutsummaryrefslogtreecommitdiffhomepage
path: root/common
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2024-07-30 16:47:16 +0200
committerBjørn Erik Pedersen <[email protected]>2024-07-31 16:44:06 +0200
commit216a69a1ef8c9f8efdec55e3680b7734a1fd52f4 (patch)
treedf5a58ba50379e89643105b97a87bd6da43a2974 /common
parente67886c038dc79755c14ec77bbeff6605953f9ef (diff)
downloadhugo-216a69a1ef8c9f8efdec55e3680b7734a1fd52f4.tar.gz
hugo-216a69a1ef8c9f8efdec55e3680b7734a1fd52f4.zip
Shorten processed image filenames
Fixes #12688 Fixes #12656
Diffstat (limited to 'common')
-rw-r--r--common/hashing/hashing.go2
-rw-r--r--common/hashing/hashing_test.go25
2 files changed, 26 insertions, 1 deletions
diff --git a/common/hashing/hashing.go b/common/hashing/hashing.go
index 42194fd4d..70aa74ecd 100644
--- a/common/hashing/hashing.go
+++ b/common/hashing/hashing.go
@@ -27,7 +27,7 @@ import (
)
// XXHashFromReader calculates the xxHash for the given reader.
-func XXHashFromReader(r io.ReadSeeker) (uint64, int64, error) {
+func XXHashFromReader(r io.Reader) (uint64, int64, error) {
h := getXxHashReadFrom()
defer putXxHashReadFrom(h)
diff --git a/common/hashing/hashing_test.go b/common/hashing/hashing_test.go
index e059b3da8..09286c035 100644
--- a/common/hashing/hashing_test.go
+++ b/common/hashing/hashing_test.go
@@ -17,6 +17,7 @@ import (
"fmt"
"math"
"strings"
+ "sync"
"testing"
qt "github.com/frankban/quicktest"
@@ -32,6 +33,30 @@ func TestXxHashFromReader(t *testing.T) {
c.Assert(got, qt.Equals, uint64(7148569436472236994))
}
+func TestXxHashFromReaderPara(t *testing.T) {
+ c := qt.New(t)
+
+ var wg sync.WaitGroup
+ for i := 0; i < 10; i++ {
+ i := i
+ wg.Add(1)
+ go func() {
+ defer wg.Done()
+ for j := 0; j < 100; j++ {
+ s := strings.Repeat("Hello ", i+j+1*42)
+ r := strings.NewReader(s)
+ got, size, err := XXHashFromReader(r)
+ c.Assert(size, qt.Equals, int64(len(s)))
+ c.Assert(err, qt.IsNil)
+ expect, _ := XXHashFromString(s)
+ c.Assert(got, qt.Equals, expect)
+ }
+ }()
+ }
+
+ wg.Wait()
+}
+
func TestXxHashFromString(t *testing.T) {
c := qt.New(t)
s := "Hello World"