diff options
| author | jenkins.ow <jenkins@outwardinc.com> | 2018-09-11 12:38:10 -0700 |
|---|---|---|
| committer | jenkins.ow <jenkins@outwardinc.com> | 2018-09-11 12:38:10 -0700 |
| commit | 1690a080b2298ca8427d204994de68fff010e146 (patch) | |
| tree | 28f811a3a8e6ce68fb882fc7f5859011086ebd46 /weed/filer2/filechunks.go | |
| parent | bc025d53055066d20ee6cf02ff4d7a30527831fe (diff) | |
| parent | 267201ff44d58d339ad2c9006ffe1d6d65e569b3 (diff) | |
| download | seaweedfs-1690a080b2298ca8427d204994de68fff010e146.tar.xz seaweedfs-1690a080b2298ca8427d204994de68fff010e146.zip | |
Merge branch 'master' of https://github.com/hans-strudle/seaweedfs
Diffstat (limited to 'weed/filer2/filechunks.go')
| -rw-r--r-- | weed/filer2/filechunks.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/weed/filer2/filechunks.go b/weed/filer2/filechunks.go index 0ac7bb43b..b248a8c59 100644 --- a/weed/filer2/filechunks.go +++ b/weed/filer2/filechunks.go @@ -1,6 +1,8 @@ package filer2 import ( + "fmt" + "hash/fnv" "math" "sort" @@ -17,6 +19,18 @@ func TotalSize(chunks []*filer_pb.FileChunk) (size uint64) { return } +func ETag(chunks []*filer_pb.FileChunk) (etag string) { + if len(chunks) == 1 { + return chunks[0].ETag + } + + h := fnv.New32a() + for _, c := range chunks { + h.Write([]byte(c.ETag)) + } + return fmt.Sprintf("%x", h.Sum32()) +} + func CompactFileChunks(chunks []*filer_pb.FileChunk) (compacted, garbage []*filer_pb.FileChunk) { visibles := nonOverlappingVisibleIntervals(chunks) |
