aboutsummaryrefslogtreecommitdiff
path: root/weed/filer2/filechunks.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2018-09-09 16:25:43 -0700
committerChris Lu <chris.lu@gmail.com>2018-09-09 16:25:43 -0700
commit164091c269b1ff54c40329947cdf1dad37a527dc (patch)
tree71bac8b171a7b6909293219f3ae6b13fff91c561 /weed/filer2/filechunks.go
parent9b3bf0e46c65ab8dfa980750cb1b805f08383df9 (diff)
downloadseaweedfs-164091c269b1ff54c40329947cdf1dad37a527dc.tar.xz
seaweedfs-164091c269b1ff54c40329947cdf1dad37a527dc.zip
add s3 multipart upload
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)