aboutsummaryrefslogtreecommitdiff
path: root/weed/filer2/filechunks.go
diff options
context:
space:
mode:
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..e47cb762f 100644
--- a/weed/filer2/filechunks.go
+++ b/weed/filer2/filechunks.go
@@ -3,6 +3,8 @@ package filer2
import (
"math"
"sort"
+ "hash/fnv"
+ "fmt"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
)
@@ -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)