SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
fix aws style Etag for chunks
Konstantin Lebedevc2269123d3e8
diff --git a/weed/filer/filechunks.go b/weed/filer/filechunks.goindex 68f308a515..346eb3cfb5 100644--- a/weed/filer/filechunks.go+++ b/weed/filer/filechunks.go@@ -2,7 +2,6 @@ package filerimport ("bytes"- "encoding/hex""fmt""github.com/chrislusf/seaweedfs/weed/wdclient""math"@@ -43,12 +42,11 @@ func ETagEntry(entry *Entry) (etag string) {func ETagChunks(chunks []*filer_pb.FileChunk) (etag string) {if len(chunks) == 1 {- return chunks[0].ETag+ return fmt.Sprintf("%x", util.Base64Md5ToBytes(chunks[0].ETag))}md5_digests := [][]byte{}for _, c := range chunks {- md5_decoded, _ := hex.DecodeString(c.ETag)- md5_digests = append(md5_digests, md5_decoded)+ md5_digests = append(md5_digests, util.Base64Md5ToBytes(c.ETag))}return fmt.Sprintf("%x-%d", util.Md5(bytes.Join(md5_digests, nil)), len(chunks))}diff --git a/weed/operation/upload_content.go b/weed/operation/upload_content.goindex 944186eeb1..8e7c6f7335 100644--- a/weed/operation/upload_content.go+++ b/weed/operation/upload_content.go@@ -39,7 +39,7 @@ func (uploadResult *UploadResult) ToPbFileChunk(fileId string, offset int64) *fiOffset: offset,Size: uint64(uploadResult.Size),Mtime: time.Now().UnixNano(),- ETag: uploadResult.ETag,+ ETag: uploadResult.ContentMd5,CipherKey: uploadResult.CipherKey,IsCompressed: uploadResult.Gzip > 0,Fid: fid,diff --git a/weed/server/filer_server_handlers_write_upload.go b/weed/server/filer_server_handlers_write_upload.goindex 3ab45453e7..b15deb9d16 100644--- a/weed/server/filer_server_handlers_write_upload.go+++ b/weed/server/filer_server_handlers_write_upload.go@@ -1,6 +1,7 @@package weed_serverimport (+ "bytes""crypto/md5""hash""io"@@ -71,6 +72,11 @@ func (fs *FilerServer) uploadReaderToChunks(w http.ResponseWriter, r *http.Requeif uploadResult.Size == 0 {break}+ uploadedMd5 := util.Base64Md5ToBytes(uploadResult.ContentMd5)+ readedMd5 := md5Hash.Sum(nil)+ if !bytes.Equal(uploadedMd5, readedMd5) {+ glog.Errorf("md5 %x does not match %x uploaded chunk %s to the volume server", readedMd5, uploadedMd5, uploadResult.Name)+ }// Save to chunk manifest structurefileChunks = append(fileChunks, uploadResult.ToPbFileChunk(fileId, chunkOffset))