aboutsummaryrefslogtreecommitdiff
path: root/weed/filer/filechunks.go
diff options
context:
space:
mode:
authorChris Lu <chrislusf@users.noreply.github.com>2020-10-05 09:46:27 -0700
committerGitHub <noreply@github.com>2020-10-05 09:46:27 -0700
commit875ee5c0d484fbb46289d34b21aea8f3d8de9344 (patch)
treef94071204dc465ca5c316faa9eabf92b24fb52e5 /weed/filer/filechunks.go
parent4fc673341f85162b06d612cb18f8a3870546a4cf (diff)
parente4f2d9eb4a592a9d8cbf2c999eea397a7fc502ec (diff)
downloadseaweedfs-875ee5c0d484fbb46289d34b21aea8f3d8de9344.tar.xz
seaweedfs-875ee5c0d484fbb46289d34b21aea8f3d8de9344.zip
Merge pull request #1508 from kmlebedev/s3_etag_like_aws
We return etag using the same algorithm as aws s3
Diffstat (limited to 'weed/filer/filechunks.go')
-rw-r--r--weed/filer/filechunks.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/weed/filer/filechunks.go b/weed/filer/filechunks.go
index db55eec00..c75a35f79 100644
--- a/weed/filer/filechunks.go
+++ b/weed/filer/filechunks.go
@@ -1,13 +1,15 @@
package filer
import (
+ "bytes"
+ "encoding/hex"
"fmt"
- "hash/fnv"
"math"
"sort"
"sync"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
+ "github.com/chrislusf/seaweedfs/weed/util"
)
func TotalSize(chunks []*filer_pb.FileChunk) (size uint64) {
@@ -42,12 +44,12 @@ func ETagChunks(chunks []*filer_pb.FileChunk) (etag string) {
if len(chunks) == 1 {
return chunks[0].ETag
}
-
- h := fnv.New32a()
+ md5_digests := [][]byte{}
for _, c := range chunks {
- h.Write([]byte(c.ETag))
+ md5_decoded, _ := hex.DecodeString(c.ETag)
+ md5_digests = append(md5_digests, md5_decoded)
}
- return fmt.Sprintf("%x", h.Sum32())
+ return fmt.Sprintf("%x-%d", util.Md5(bytes.Join(md5_digests, nil)), len(chunks))
}
func CompactFileChunks(lookupFileIdFn LookupFileIdFunctionType, chunks []*filer_pb.FileChunk) (compacted, garbage []*filer_pb.FileChunk) {