aboutsummaryrefslogtreecommitdiff
path: root/weed/filer2/filechunks.go
diff options
context:
space:
mode:
authorjenkins.ow <jenkins@outwardinc.com>2018-09-11 12:38:10 -0700
committerjenkins.ow <jenkins@outwardinc.com>2018-09-11 12:38:10 -0700
commit1690a080b2298ca8427d204994de68fff010e146 (patch)
tree28f811a3a8e6ce68fb882fc7f5859011086ebd46 /weed/filer2/filechunks.go
parentbc025d53055066d20ee6cf02ff4d7a30527831fe (diff)
parent267201ff44d58d339ad2c9006ffe1d6d65e569b3 (diff)
downloadseaweedfs-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.go14
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)