From 824c8a39f146ef3b8c0271ed4d9a4877716081f1 Mon Sep 17 00:00:00 2001 From: Krishna Srinivas Date: Thu, 19 May 2016 02:07:28 +0530 Subject: [PATCH] XL/Multipart: If the part is already uploaded ignore the newly uploaded part. (#1677) Fixes #1644 --- object-common-multipart.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/object-common-multipart.go b/object-common-multipart.go index 8907c0174..824e461e4 100644 --- a/object-common-multipart.go +++ b/object-common-multipart.go @@ -205,6 +205,14 @@ func putObjectPartCommon(storage StorageAPI, bucket string, object string, uploa partSuffixMD5 := fmt.Sprintf("%.5d.%s", partID, newMD5Hex) partSuffixMD5Path := path.Join(mpartMetaPrefix, bucket, object, uploadID, partSuffixMD5) + if _, err = storage.StatFile(minioMetaBucket, partSuffixMD5Path); err == nil { + // Part already uploaded as md5sum matches with the previous part. + // Just delete the temporary file. + if err = storage.DeleteFile(minioMetaBucket, partSuffixPath); err != nil { + return "", toObjectErr(err, minioMetaBucket, partSuffixPath) + } + return newMD5Hex, nil + } err = storage.RenameFile(minioMetaBucket, partSuffixPath, minioMetaBucket, partSuffixMD5Path) if err != nil { if derr := storage.DeleteFile(minioMetaBucket, partSuffixPath); derr != nil {