aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chrislusf@users.noreply.github.com>2021-07-01 21:04:21 -0700
committerGitHub <noreply@github.com>2021-07-01 21:04:21 -0700
commit3d9ec2e0b600bdefdff0705a1f030abb0cac9ee4 (patch)
tree34ad1bd9c10252e40b0617598f3539d31773d5a5
parentc6d4c16079875dfbe0d350b83fbacccaaa9c15db (diff)
parent1a4db87e19a577873d7f354673ac1cbf825597ae (diff)
downloadseaweedfs-3d9ec2e0b600bdefdff0705a1f030abb0cac9ee4.tar.xz
seaweedfs-3d9ec2e0b600bdefdff0705a1f030abb0cac9ee4.zip
Merge pull request #2174 from qwedsazzcc/master
fix s3 metadata error with multipart upload
-rw-r--r--weed/pb/filer_pb/filer_client.go6
-rw-r--r--weed/s3api/filer_multipart.go17
-rw-r--r--weed/s3api/filer_util.go4
3 files changed, 23 insertions, 4 deletions
diff --git a/weed/pb/filer_pb/filer_client.go b/weed/pb/filer_pb/filer_client.go
index 65bd85c84..12f918137 100644
--- a/weed/pb/filer_pb/filer_client.go
+++ b/weed/pb/filer_pb/filer_client.go
@@ -236,7 +236,7 @@ func Mkdir(filerClient FilerClient, parentDirectoryPath string, dirName string,
})
}
-func MkFile(filerClient FilerClient, parentDirectoryPath string, fileName string, chunks []*FileChunk) error {
+func MkFile(filerClient FilerClient, parentDirectoryPath string, fileName string, chunks []*FileChunk, fn func(entry *Entry)) error {
return filerClient.WithFilerClient(func(client SeaweedFilerClient) error {
entry := &Entry{
@@ -252,6 +252,10 @@ func MkFile(filerClient FilerClient, parentDirectoryPath string, fileName string
Chunks: chunks,
}
+ if fn != nil {
+ fn(entry)
+ }
+
request := &CreateEntryRequest{
Directory: parentDirectoryPath,
Entry: entry,
diff --git a/weed/s3api/filer_multipart.go b/weed/s3api/filer_multipart.go
index 61132c082..5d7bf2ac3 100644
--- a/weed/s3api/filer_multipart.go
+++ b/weed/s3api/filer_multipart.go
@@ -71,6 +71,12 @@ func (s3a *S3ApiServer) completeMultipartUpload(input *s3.CompleteMultipartUploa
return nil, s3err.ErrNoSuchUpload
}
+ pentry, err := s3a.getEntry(s3a.genUploadsFolder(*input.Bucket),*input.UploadId)
+ if err != nil {
+ glog.Errorf("completeMultipartUpload %s %s error: %v", *input.Bucket, *input.UploadId, err)
+ return nil, s3err.ErrNoSuchUpload
+ }
+
var finalParts []*filer_pb.FileChunk
var offset int64
@@ -106,7 +112,16 @@ func (s3a *S3ApiServer) completeMultipartUpload(input *s3.CompleteMultipartUploa
dirName = dirName[:len(dirName)-1]
}
- err = s3a.mkFile(dirName, entryName, finalParts)
+ err = s3a.mkFile(dirName, entryName, finalParts,func(entry *filer_pb.Entry) {
+ if entry.Extended == nil {
+ entry.Extended = make(map[string][]byte)
+ }
+ for k,v := range pentry.Extended{
+ if k != "key" {
+ entry.Extended[k] = v
+ }
+ }
+ })
if err != nil {
glog.Errorf("completeMultipartUpload %s/%s error: %v", dirName, entryName, err)
diff --git a/weed/s3api/filer_util.go b/weed/s3api/filer_util.go
index 1803332a3..92267a154 100644
--- a/weed/s3api/filer_util.go
+++ b/weed/s3api/filer_util.go
@@ -15,9 +15,9 @@ func (s3a *S3ApiServer) mkdir(parentDirectoryPath string, dirName string, fn fun
}
-func (s3a *S3ApiServer) mkFile(parentDirectoryPath string, fileName string, chunks []*filer_pb.FileChunk) error {
+func (s3a *S3ApiServer) mkFile(parentDirectoryPath string, fileName string, chunks []*filer_pb.FileChunk, fn func(entry *filer_pb.Entry)) error {
- return filer_pb.MkFile(s3a, parentDirectoryPath, fileName, chunks)
+ return filer_pb.MkFile(s3a, parentDirectoryPath, fileName, chunks,fn)
}