diff options
| author | hilimd <68371223+hilimd@users.noreply.github.com> | 2020-10-10 13:07:57 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-10 13:07:57 +0800 |
| commit | 411e49f96494629fa3da334e8dc7cc15bd4d19cd (patch) | |
| tree | 1756f0a2f86c871a6db67df7ecbd509c9df32233 /weed/filer/filechunks.go | |
| parent | ac162fc85769cb1b2a1f8694f9644eae7d0ce6c8 (diff) | |
| parent | 4a15e9c830de1b654515308e5be8380ffa34aefa (diff) | |
| download | seaweedfs-411e49f96494629fa3da334e8dc7cc15bd4d19cd.tar.xz seaweedfs-411e49f96494629fa3da334e8dc7cc15bd4d19cd.zip | |
Merge pull request #23 from chrislusf/master
sync
Diffstat (limited to 'weed/filer/filechunks.go')
| -rw-r--r-- | weed/filer/filechunks.go | 12 |
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) { |
