2016-05-02 19:57:31 -04:00
|
|
|
/*
|
2017-03-18 14:28:41 -04:00
|
|
|
* Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
|
2016-05-02 19:57:31 -04:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2016-08-18 19:23:42 -04:00
|
|
|
package cmd
|
2016-05-02 19:57:31 -04:00
|
|
|
|
|
|
|
import (
|
2017-10-24 15:25:42 -04:00
|
|
|
"encoding/hex"
|
2016-05-02 19:57:31 -04:00
|
|
|
"fmt"
|
|
|
|
"io"
|
2017-01-16 20:05:00 -05:00
|
|
|
"os"
|
|
|
|
pathutil "path"
|
2016-05-03 19:10:24 -04:00
|
|
|
"strings"
|
2016-05-20 23:48:47 -04:00
|
|
|
"time"
|
2016-12-19 22:32:55 -05:00
|
|
|
|
2017-11-25 14:58:29 -05:00
|
|
|
"github.com/minio/minio/pkg/errors"
|
2017-10-22 01:30:34 -04:00
|
|
|
"github.com/minio/minio/pkg/hash"
|
2017-01-26 15:51:12 -05:00
|
|
|
"github.com/minio/minio/pkg/lock"
|
2016-05-02 19:57:31 -04:00
|
|
|
)
|
|
|
|
|
2017-01-26 15:51:12 -05:00
|
|
|
// Returns if the prefix is a multipart upload.
|
|
|
|
func (fs fsObjects) isMultipartUpload(bucket, prefix string) bool {
|
|
|
|
uploadsIDPath := pathJoin(fs.fsPath, bucket, prefix, uploadsJSONFile)
|
|
|
|
_, err := fsStatFile(uploadsIDPath)
|
|
|
|
if err != nil {
|
2017-11-25 14:58:29 -05:00
|
|
|
if errors.Cause(err) == errFileNotFound {
|
2017-01-26 15:51:12 -05:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
errorIf(err, "Unable to access uploads.json "+uploadsIDPath)
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2017-04-14 15:06:24 -04:00
|
|
|
// Delete uploads.json file wrapper
|
2017-01-26 15:51:12 -05:00
|
|
|
func (fs fsObjects) deleteUploadsJSON(bucket, object, uploadID string) error {
|
|
|
|
multipartBucketPath := pathJoin(fs.fsPath, minioMetaMultipartBucket)
|
|
|
|
uploadPath := pathJoin(multipartBucketPath, bucket, object)
|
|
|
|
uploadsMetaPath := pathJoin(uploadPath, uploadsJSONFile)
|
|
|
|
|
2017-04-14 15:06:24 -04:00
|
|
|
tmpDir := pathJoin(fs.fsPath, minioMetaTmpBucket, fs.fsUUID)
|
2017-01-26 15:51:12 -05:00
|
|
|
|
2017-04-14 15:06:24 -04:00
|
|
|
return fsRemoveMeta(multipartBucketPath, uploadsMetaPath, tmpDir)
|
2017-01-26 15:51:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// Removes the uploadID, called either by CompleteMultipart of AbortMultipart. If the resuling uploads
|
|
|
|
// slice is empty then we remove/purge the file.
|
2017-09-28 11:09:28 -04:00
|
|
|
func (fs fsObjects) removeUploadID(bucket, object, uploadID string, rwlk *lock.LockedFile) (bool, error) {
|
2017-01-26 15:51:12 -05:00
|
|
|
uploadIDs := uploadsV1{}
|
|
|
|
_, err := uploadIDs.ReadFrom(rwlk)
|
|
|
|
if err != nil {
|
2017-09-28 11:09:28 -04:00
|
|
|
return false, err
|
2017-01-26 15:51:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// Removes upload id from the uploads list.
|
|
|
|
uploadIDs.RemoveUploadID(uploadID)
|
|
|
|
|
|
|
|
// Check this is the last entry.
|
|
|
|
if uploadIDs.IsEmpty() {
|
|
|
|
// No more uploads left, so we delete `uploads.json` file.
|
2017-09-28 11:09:28 -04:00
|
|
|
return true, fs.deleteUploadsJSON(bucket, object, uploadID)
|
2017-01-26 15:51:12 -05:00
|
|
|
} // else not empty
|
|
|
|
|
|
|
|
// Write update `uploads.json`.
|
|
|
|
_, err = uploadIDs.WriteTo(rwlk)
|
2017-09-28 11:09:28 -04:00
|
|
|
return false, err
|
2017-01-26 15:51:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// Adds a new uploadID if no previous `uploads.json` is
|
|
|
|
// found we initialize a new one.
|
|
|
|
func (fs fsObjects) addUploadID(bucket, object, uploadID string, initiated time.Time, rwlk *lock.LockedFile) error {
|
|
|
|
uploadIDs := uploadsV1{}
|
|
|
|
|
|
|
|
_, err := uploadIDs.ReadFrom(rwlk)
|
|
|
|
// For all unexpected errors, we return.
|
2017-11-25 14:58:29 -05:00
|
|
|
if err != nil && errors.Cause(err) != io.EOF {
|
2017-01-26 15:51:12 -05:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we couldn't read anything, we assume a default
|
|
|
|
// (empty) upload info.
|
2017-11-25 14:58:29 -05:00
|
|
|
if errors.Cause(err) == io.EOF {
|
2017-01-26 15:51:12 -05:00
|
|
|
uploadIDs = newUploadsV1("fs")
|
|
|
|
}
|
|
|
|
|
|
|
|
// Adds new upload id to the list.
|
|
|
|
uploadIDs.AddUploadID(uploadID, initiated)
|
|
|
|
|
|
|
|
// Write update `uploads.json`.
|
|
|
|
_, err = uploadIDs.WriteTo(rwlk)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-01-16 20:05:00 -05:00
|
|
|
// listMultipartUploadIDs - list all the upload ids from a marker up to 'count'.
|
2017-11-14 03:25:10 -05:00
|
|
|
func (fs fsObjects) listMultipartUploadIDs(bucketName, objectName, uploadIDMarker string, count int) ([]MultipartInfo, bool, error) {
|
|
|
|
var uploads []MultipartInfo
|
2017-01-16 20:05:00 -05:00
|
|
|
|
|
|
|
// Hold the lock so that two parallel complete-multipart-uploads
|
|
|
|
// do not leave a stale uploads.json behind.
|
|
|
|
objectMPartPathLock := globalNSMutex.NewNSLock(minioMetaMultipartBucket, pathJoin(bucketName, objectName))
|
2017-08-31 14:29:22 -04:00
|
|
|
if err := objectMPartPathLock.GetRLock(globalListingTimeout); err != nil {
|
2017-11-25 14:58:29 -05:00
|
|
|
return nil, false, errors.Trace(err)
|
2017-08-31 14:29:22 -04:00
|
|
|
}
|
2017-01-16 20:05:00 -05:00
|
|
|
defer objectMPartPathLock.RUnlock()
|
|
|
|
|
|
|
|
uploadsPath := pathJoin(bucketName, objectName, uploadsJSONFile)
|
|
|
|
rlk, err := fs.rwPool.Open(pathJoin(fs.fsPath, minioMetaMultipartBucket, uploadsPath))
|
|
|
|
if err != nil {
|
|
|
|
if err == errFileNotFound || err == errFileAccessDenied {
|
|
|
|
return nil, true, nil
|
|
|
|
}
|
2017-11-25 14:58:29 -05:00
|
|
|
return nil, false, errors.Trace(err)
|
2017-01-16 20:05:00 -05:00
|
|
|
}
|
|
|
|
defer fs.rwPool.Close(pathJoin(fs.fsPath, minioMetaMultipartBucket, uploadsPath))
|
|
|
|
|
|
|
|
// Read `uploads.json`.
|
|
|
|
uploadIDs := uploadsV1{}
|
2017-01-25 15:29:06 -05:00
|
|
|
if _, err = uploadIDs.ReadFrom(rlk.LockedFile); err != nil {
|
2017-01-16 20:05:00 -05:00
|
|
|
return nil, false, err
|
|
|
|
}
|
|
|
|
|
|
|
|
index := 0
|
|
|
|
if uploadIDMarker != "" {
|
|
|
|
for ; index < len(uploadIDs.Uploads); index++ {
|
|
|
|
if uploadIDs.Uploads[index].UploadID == uploadIDMarker {
|
|
|
|
// Skip the uploadID as it would already be listed in previous listing.
|
|
|
|
index++
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for index < len(uploadIDs.Uploads) {
|
2017-11-14 03:25:10 -05:00
|
|
|
uploads = append(uploads, MultipartInfo{
|
2017-01-16 20:05:00 -05:00
|
|
|
Object: objectName,
|
|
|
|
UploadID: uploadIDs.Uploads[index].UploadID,
|
|
|
|
Initiated: uploadIDs.Uploads[index].Initiated,
|
|
|
|
})
|
|
|
|
count--
|
|
|
|
index++
|
|
|
|
if count == 0 {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
end := (index == len(uploadIDs.Uploads))
|
|
|
|
return uploads, end, nil
|
|
|
|
}
|
|
|
|
|
2017-10-05 19:08:25 -04:00
|
|
|
// listMultipartUploadsCleanup - lists all multipart uploads. Called by fs.cleanupStaleMultipartUpload()
|
|
|
|
func (fs fsObjects) listMultipartUploadsCleanup(bucket, prefix, keyMarker, uploadIDMarker, delimiter string, maxUploads int) (lmi ListMultipartsInfo, e error) {
|
2016-05-03 19:10:24 -04:00
|
|
|
result := ListMultipartsInfo{}
|
|
|
|
recursive := true
|
|
|
|
if delimiter == slashSeparator {
|
|
|
|
recursive = false
|
|
|
|
}
|
|
|
|
|
|
|
|
result.IsTruncated = true
|
|
|
|
result.MaxUploads = maxUploads
|
2016-05-26 17:43:17 -04:00
|
|
|
result.KeyMarker = keyMarker
|
|
|
|
result.Prefix = prefix
|
|
|
|
result.Delimiter = delimiter
|
2016-05-03 19:10:24 -04:00
|
|
|
|
|
|
|
// Not using path.Join() as it strips off the trailing '/'.
|
2016-11-22 16:15:06 -05:00
|
|
|
multipartPrefixPath := pathJoin(bucket, prefix)
|
2016-05-17 14:44:32 -04:00
|
|
|
if prefix == "" {
|
|
|
|
// Should have a trailing "/" if prefix is ""
|
|
|
|
// For ex. multipartPrefixPath should be "multipart/bucket/" if prefix is ""
|
|
|
|
multipartPrefixPath += slashSeparator
|
|
|
|
}
|
2016-05-03 19:10:24 -04:00
|
|
|
multipartMarkerPath := ""
|
|
|
|
if keyMarker != "" {
|
2016-11-22 16:15:06 -05:00
|
|
|
multipartMarkerPath = pathJoin(bucket, keyMarker)
|
2016-05-03 19:10:24 -04:00
|
|
|
}
|
2017-01-16 20:05:00 -05:00
|
|
|
|
2017-11-14 03:25:10 -05:00
|
|
|
var uploads []MultipartInfo
|
2016-05-26 17:43:17 -04:00
|
|
|
var err error
|
|
|
|
var eof bool
|
2017-01-16 20:05:00 -05:00
|
|
|
|
2016-05-26 17:43:17 -04:00
|
|
|
if uploadIDMarker != "" {
|
2017-01-16 20:05:00 -05:00
|
|
|
uploads, _, err = fs.listMultipartUploadIDs(bucket, keyMarker, uploadIDMarker, maxUploads)
|
2016-05-26 17:43:17 -04:00
|
|
|
if err != nil {
|
2017-06-21 22:53:09 -04:00
|
|
|
return lmi, err
|
2016-05-26 17:43:17 -04:00
|
|
|
}
|
|
|
|
maxUploads = maxUploads - len(uploads)
|
2016-05-03 19:10:24 -04:00
|
|
|
}
|
2017-01-16 20:05:00 -05:00
|
|
|
|
2016-07-07 12:06:35 -04:00
|
|
|
var walkResultCh chan treeWalkResult
|
|
|
|
var endWalkCh chan struct{}
|
2017-01-16 20:05:00 -05:00
|
|
|
|
|
|
|
// true only for xl.ListObjectsHeal(), set to false.
|
|
|
|
heal := false
|
|
|
|
|
|
|
|
// Proceed to list only if we have more uploads to be listed.
|
2016-05-26 17:43:17 -04:00
|
|
|
if maxUploads > 0 {
|
2017-01-16 20:05:00 -05:00
|
|
|
listPrms := listParams{minioMetaMultipartBucket, recursive, multipartMarkerPath, multipartPrefixPath, heal}
|
|
|
|
|
|
|
|
// Pop out any previously waiting marker.
|
|
|
|
walkResultCh, endWalkCh = fs.listPool.Release(listPrms)
|
2016-06-24 19:41:57 -04:00
|
|
|
if walkResultCh == nil {
|
|
|
|
endWalkCh = make(chan struct{})
|
2016-07-17 18:16:52 -04:00
|
|
|
isLeaf := fs.isMultipartUpload
|
2017-01-16 20:05:00 -05:00
|
|
|
listDir := fs.listDirFactory(isLeaf)
|
|
|
|
walkResultCh = startTreeWalk(minioMetaMultipartBucket, multipartPrefixPath,
|
|
|
|
multipartMarkerPath, recursive, listDir, isLeaf, endWalkCh)
|
2016-05-26 17:43:17 -04:00
|
|
|
}
|
2017-01-16 20:05:00 -05:00
|
|
|
|
|
|
|
// List until maxUploads requested.
|
2016-05-26 17:43:17 -04:00
|
|
|
for maxUploads > 0 {
|
2016-06-24 19:41:57 -04:00
|
|
|
walkResult, ok := <-walkResultCh
|
2016-05-26 17:43:17 -04:00
|
|
|
if !ok {
|
|
|
|
// Closed channel.
|
|
|
|
eof = true
|
|
|
|
break
|
|
|
|
}
|
2017-01-16 20:05:00 -05:00
|
|
|
|
2016-05-26 17:43:17 -04:00
|
|
|
// For any walk error return right away.
|
|
|
|
if walkResult.err != nil {
|
|
|
|
// File not found or Disk not found is a valid case.
|
2017-11-25 14:58:29 -05:00
|
|
|
if errors.IsErrIgnored(walkResult.err, fsTreeWalkIgnoredErrs...) {
|
2016-05-26 17:43:17 -04:00
|
|
|
eof = true
|
|
|
|
break
|
|
|
|
}
|
2017-06-21 22:53:09 -04:00
|
|
|
return lmi, walkResult.err
|
2016-05-26 17:43:17 -04:00
|
|
|
}
|
2017-01-16 20:05:00 -05:00
|
|
|
|
2016-11-22 16:15:06 -05:00
|
|
|
entry := strings.TrimPrefix(walkResult.entry, retainSlash(bucket))
|
2017-02-16 17:52:14 -05:00
|
|
|
if hasSuffix(walkResult.entry, slashSeparator) {
|
2017-11-14 03:25:10 -05:00
|
|
|
uploads = append(uploads, MultipartInfo{
|
2016-05-26 17:43:17 -04:00
|
|
|
Object: entry,
|
|
|
|
})
|
|
|
|
maxUploads--
|
|
|
|
if maxUploads == 0 {
|
|
|
|
if walkResult.end {
|
|
|
|
eof = true
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
continue
|
|
|
|
}
|
2017-01-16 20:05:00 -05:00
|
|
|
|
2017-11-14 03:25:10 -05:00
|
|
|
var tmpUploads []MultipartInfo
|
2016-05-26 17:43:17 -04:00
|
|
|
var end bool
|
|
|
|
uploadIDMarker = ""
|
2016-08-31 14:39:08 -04:00
|
|
|
|
2017-01-16 20:05:00 -05:00
|
|
|
tmpUploads, end, err = fs.listMultipartUploadIDs(bucket, entry, uploadIDMarker, maxUploads)
|
2016-05-26 17:43:17 -04:00
|
|
|
if err != nil {
|
2017-06-21 22:53:09 -04:00
|
|
|
return lmi, err
|
2016-05-26 17:43:17 -04:00
|
|
|
}
|
2017-01-16 20:05:00 -05:00
|
|
|
|
2016-05-26 17:43:17 -04:00
|
|
|
uploads = append(uploads, tmpUploads...)
|
|
|
|
maxUploads -= len(tmpUploads)
|
|
|
|
if walkResult.end && end {
|
|
|
|
eof = true
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-01-16 20:05:00 -05:00
|
|
|
|
2016-05-26 17:43:17 -04:00
|
|
|
// Loop through all the received uploads fill in the multiparts result.
|
|
|
|
for _, upload := range uploads {
|
2016-05-03 19:10:24 -04:00
|
|
|
var objectName string
|
|
|
|
var uploadID string
|
2017-02-16 17:52:14 -05:00
|
|
|
if hasSuffix(upload.Object, slashSeparator) {
|
2016-05-03 19:10:24 -04:00
|
|
|
// All directory entries are common prefixes.
|
|
|
|
uploadID = "" // Upload ids are empty for CommonPrefixes.
|
2016-05-26 17:43:17 -04:00
|
|
|
objectName = upload.Object
|
2016-05-03 19:10:24 -04:00
|
|
|
result.CommonPrefixes = append(result.CommonPrefixes, objectName)
|
|
|
|
} else {
|
2016-05-26 17:43:17 -04:00
|
|
|
uploadID = upload.UploadID
|
|
|
|
objectName = upload.Object
|
|
|
|
result.Uploads = append(result.Uploads, upload)
|
2016-05-03 19:10:24 -04:00
|
|
|
}
|
|
|
|
result.NextKeyMarker = objectName
|
|
|
|
result.NextUploadIDMarker = uploadID
|
|
|
|
}
|
2016-07-07 12:06:35 -04:00
|
|
|
|
|
|
|
if !eof {
|
|
|
|
// Save the go-routine state in the pool so that it can continue from where it left off on
|
|
|
|
// the next request.
|
2016-08-17 14:36:33 -04:00
|
|
|
fs.listPool.Set(listParams{bucket, recursive, result.NextKeyMarker, prefix, heal}, walkResultCh, endWalkCh)
|
2016-07-07 12:06:35 -04:00
|
|
|
}
|
|
|
|
|
2016-05-03 19:10:24 -04:00
|
|
|
result.IsTruncated = !eof
|
|
|
|
if !result.IsTruncated {
|
|
|
|
result.NextKeyMarker = ""
|
|
|
|
result.NextUploadIDMarker = ""
|
|
|
|
}
|
2017-01-16 20:05:00 -05:00
|
|
|
|
|
|
|
// Success.
|
2016-05-03 19:10:24 -04:00
|
|
|
return result, nil
|
|
|
|
}
|
|
|
|
|
2017-10-05 19:08:25 -04:00
|
|
|
// ListMultipartUploads - lists all the uploadIDs for the specified object.
|
|
|
|
// We do not support prefix based listing.
|
|
|
|
func (fs fsObjects) ListMultipartUploads(bucket, object, keyMarker, uploadIDMarker, delimiter string, maxUploads int) (lmi ListMultipartsInfo, e error) {
|
|
|
|
if err := checkListMultipartArgs(bucket, object, keyMarker, uploadIDMarker, delimiter, fs); err != nil {
|
2017-08-04 13:45:57 -04:00
|
|
|
return lmi, err
|
|
|
|
}
|
|
|
|
|
|
|
|
if _, err := fs.statBucketDir(bucket); err != nil {
|
|
|
|
return lmi, toObjectErr(err, bucket)
|
|
|
|
}
|
|
|
|
|
2017-10-05 19:08:25 -04:00
|
|
|
result := ListMultipartsInfo{}
|
|
|
|
|
|
|
|
result.IsTruncated = true
|
|
|
|
result.MaxUploads = maxUploads
|
|
|
|
result.KeyMarker = keyMarker
|
|
|
|
result.Prefix = object
|
|
|
|
result.Delimiter = delimiter
|
|
|
|
|
|
|
|
uploads, _, err := fs.listMultipartUploadIDs(bucket, object, uploadIDMarker, maxUploads)
|
|
|
|
if err != nil {
|
2017-06-21 22:53:09 -04:00
|
|
|
return lmi, err
|
2016-06-02 15:18:56 -04:00
|
|
|
}
|
2017-01-16 20:05:00 -05:00
|
|
|
|
2017-10-05 19:08:25 -04:00
|
|
|
result.NextKeyMarker = object
|
|
|
|
// Loop through all the received uploads fill in the multiparts result.
|
|
|
|
for _, upload := range uploads {
|
|
|
|
uploadID := upload.UploadID
|
|
|
|
result.Uploads = append(result.Uploads, upload)
|
|
|
|
result.NextUploadIDMarker = uploadID
|
2017-01-16 20:05:00 -05:00
|
|
|
}
|
|
|
|
|
2017-10-05 19:08:25 -04:00
|
|
|
result.IsTruncated = len(uploads) == maxUploads
|
|
|
|
|
|
|
|
if !result.IsTruncated {
|
|
|
|
result.NextKeyMarker = ""
|
|
|
|
result.NextUploadIDMarker = ""
|
|
|
|
}
|
|
|
|
|
|
|
|
return result, nil
|
2016-05-20 23:48:47 -04:00
|
|
|
}
|
|
|
|
|
2016-06-02 15:18:56 -04:00
|
|
|
// newMultipartUpload - wrapper for initializing a new multipart
|
|
|
|
// request, returns back a unique upload id.
|
|
|
|
//
|
|
|
|
// Internally this function creates 'uploads.json' associated for the
|
2016-09-06 23:31:50 -04:00
|
|
|
// incoming object at '.minio.sys/multipart/bucket/object/uploads.json' on
|
2016-06-02 15:18:56 -04:00
|
|
|
// all the disks. `uploads.json` carries metadata regarding on going
|
|
|
|
// multipart operation on the object.
|
|
|
|
func (fs fsObjects) newMultipartUpload(bucket string, object string, meta map[string]string) (uploadID string, err error) {
|
|
|
|
// Initialize `fs.json` values.
|
|
|
|
fsMeta := newFSMetaV1()
|
2016-08-17 16:26:08 -04:00
|
|
|
|
2016-11-11 19:36:07 -05:00
|
|
|
// Save additional metadata.
|
|
|
|
fsMeta.Meta = meta
|
2016-06-02 15:18:56 -04:00
|
|
|
|
2016-11-22 19:52:37 -05:00
|
|
|
uploadID = mustGetUUID()
|
2017-03-18 14:28:41 -04:00
|
|
|
initiated := UTCNow()
|
2017-01-16 20:05:00 -05:00
|
|
|
|
2016-11-22 18:29:39 -05:00
|
|
|
// Add upload ID to uploads.json
|
2017-01-16 20:05:00 -05:00
|
|
|
uploadsPath := pathJoin(bucket, object, uploadsJSONFile)
|
|
|
|
rwlk, err := fs.rwPool.Create(pathJoin(fs.fsPath, minioMetaMultipartBucket, uploadsPath))
|
|
|
|
if err != nil {
|
2017-11-25 14:58:29 -05:00
|
|
|
return "", toObjectErr(errors.Trace(err), bucket, object)
|
2016-06-02 15:18:56 -04:00
|
|
|
}
|
2017-01-16 20:05:00 -05:00
|
|
|
defer rwlk.Close()
|
|
|
|
|
|
|
|
uploadIDPath := pathJoin(bucket, object, uploadID)
|
|
|
|
fsMetaPath := pathJoin(fs.fsPath, minioMetaMultipartBucket, uploadIDPath, fsMetaJSONFile)
|
|
|
|
metaFile, err := fs.rwPool.Create(fsMetaPath)
|
|
|
|
if err != nil {
|
2017-11-25 14:58:29 -05:00
|
|
|
return "", toObjectErr(errors.Trace(err), bucket, object)
|
2017-01-16 20:05:00 -05:00
|
|
|
}
|
|
|
|
defer metaFile.Close()
|
|
|
|
|
|
|
|
// Add a new upload id.
|
|
|
|
if err = fs.addUploadID(bucket, object, uploadID, initiated, rwlk); err != nil {
|
|
|
|
return "", toObjectErr(err, bucket, object)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write all the set metadata.
|
|
|
|
if _, err = fsMeta.WriteTo(metaFile); err != nil {
|
|
|
|
return "", toObjectErr(err, bucket, object)
|
2016-06-02 15:18:56 -04:00
|
|
|
}
|
2017-01-16 20:05:00 -05:00
|
|
|
|
2016-06-02 15:18:56 -04:00
|
|
|
// Return success.
|
|
|
|
return uploadID, nil
|
2016-05-20 23:48:47 -04:00
|
|
|
}
|
|
|
|
|
2016-06-02 15:18:56 -04:00
|
|
|
// NewMultipartUpload - initialize a new multipart upload, returns a
|
|
|
|
// unique id. The unique id returned here is of UUID form, for each
|
|
|
|
// subsequent request each UUID is unique.
|
|
|
|
//
|
|
|
|
// Implements S3 compatible initiate multipart API.
|
|
|
|
func (fs fsObjects) NewMultipartUpload(bucket, object string, meta map[string]string) (string, error) {
|
2016-12-02 02:15:17 -05:00
|
|
|
if err := checkNewMultipartArgs(bucket, object, fs); err != nil {
|
|
|
|
return "", err
|
2016-05-20 23:48:47 -04:00
|
|
|
}
|
2017-01-16 20:05:00 -05:00
|
|
|
|
|
|
|
if _, err := fs.statBucketDir(bucket); err != nil {
|
|
|
|
return "", toObjectErr(err, bucket)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Hold the lock so that two parallel complete-multipart-uploads
|
|
|
|
// do not leave a stale uploads.json behind.
|
|
|
|
objectMPartPathLock := globalNSMutex.NewNSLock(minioMetaMultipartBucket, pathJoin(bucket, object))
|
2017-08-31 14:29:22 -04:00
|
|
|
if err := objectMPartPathLock.GetLock(globalOperationTimeout); err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
2017-01-16 20:05:00 -05:00
|
|
|
defer objectMPartPathLock.Unlock()
|
|
|
|
|
2016-06-02 15:18:56 -04:00
|
|
|
return fs.newMultipartUpload(bucket, object, meta)
|
|
|
|
}
|
2016-05-20 23:48:47 -04:00
|
|
|
|
2016-08-31 16:42:57 -04:00
|
|
|
// Returns if a new part can be appended to fsAppendDataFile.
|
|
|
|
func partToAppend(fsMeta fsMetaV1, fsAppendMeta fsMetaV1) (part objectPartInfo, appendNeeded bool) {
|
|
|
|
if len(fsMeta.Parts) == 0 {
|
|
|
|
return
|
|
|
|
}
|
2017-01-16 20:05:00 -05:00
|
|
|
|
2016-08-31 16:42:57 -04:00
|
|
|
// As fsAppendMeta.Parts will be sorted len(fsAppendMeta.Parts) will naturally be the next part number
|
|
|
|
nextPartNum := len(fsAppendMeta.Parts) + 1
|
|
|
|
nextPartIndex := fsMeta.ObjectPartIndex(nextPartNum)
|
|
|
|
if nextPartIndex == -1 {
|
|
|
|
return
|
|
|
|
}
|
2017-01-16 20:05:00 -05:00
|
|
|
|
2016-08-31 16:42:57 -04:00
|
|
|
return fsMeta.Parts[nextPartIndex], true
|
|
|
|
}
|
|
|
|
|
2017-01-31 12:38:34 -05:00
|
|
|
// CopyObjectPart - similar to PutObjectPart but reads data from an existing
|
|
|
|
// object. Internally incoming data is written to '.minio.sys/tmp' location
|
|
|
|
// and safely renamed to '.minio.sys/multipart' for reach parts.
|
2017-06-21 22:53:09 -04:00
|
|
|
func (fs fsObjects) CopyObjectPart(srcBucket, srcObject, dstBucket, dstObject, uploadID string, partID int, startOffset int64, length int64) (pi PartInfo, e error) {
|
2017-01-31 12:38:34 -05:00
|
|
|
if err := checkNewMultipartArgs(srcBucket, srcObject, fs); err != nil {
|
2017-06-21 22:53:09 -04:00
|
|
|
return pi, err
|
2017-01-31 12:38:34 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// Initialize pipe.
|
|
|
|
pipeReader, pipeWriter := io.Pipe()
|
|
|
|
|
|
|
|
go func() {
|
|
|
|
if gerr := fs.GetObject(srcBucket, srcObject, startOffset, length, pipeWriter); gerr != nil {
|
|
|
|
errorIf(gerr, "Unable to read %s/%s.", srcBucket, srcObject)
|
|
|
|
pipeWriter.CloseWithError(gerr)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
pipeWriter.Close() // Close writer explicitly signalling we wrote all data.
|
|
|
|
}()
|
|
|
|
|
2017-10-22 01:30:34 -04:00
|
|
|
hashReader, err := hash.NewReader(pipeReader, length, "", "")
|
|
|
|
if err != nil {
|
|
|
|
return pi, toObjectErr(err, dstBucket, dstObject)
|
|
|
|
}
|
|
|
|
|
|
|
|
partInfo, err := fs.PutObjectPart(dstBucket, dstObject, uploadID, partID, hashReader)
|
2017-01-31 12:38:34 -05:00
|
|
|
if err != nil {
|
2017-06-21 22:53:09 -04:00
|
|
|
return pi, toObjectErr(err, dstBucket, dstObject)
|
2017-01-31 12:38:34 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// Explicitly close the reader.
|
|
|
|
pipeReader.Close()
|
|
|
|
|
|
|
|
return partInfo, nil
|
|
|
|
}
|
|
|
|
|
2016-06-02 18:19:13 -04:00
|
|
|
// PutObjectPart - reads incoming data until EOF for the part file on
|
2016-06-02 15:18:56 -04:00
|
|
|
// an ongoing multipart transaction. Internally incoming data is
|
2016-09-06 23:31:50 -04:00
|
|
|
// written to '.minio.sys/tmp' location and safely renamed to
|
|
|
|
// '.minio.sys/multipart' for reach parts.
|
2017-10-22 01:30:34 -04:00
|
|
|
func (fs fsObjects) PutObjectPart(bucket, object, uploadID string, partID int, data *hash.Reader) (pi PartInfo, e error) {
|
2016-12-02 02:15:17 -05:00
|
|
|
if err := checkPutObjectPartArgs(bucket, object, fs); err != nil {
|
2017-06-21 22:53:09 -04:00
|
|
|
return pi, err
|
2016-06-02 18:19:13 -04:00
|
|
|
}
|
|
|
|
|
2017-01-16 20:05:00 -05:00
|
|
|
if _, err := fs.statBucketDir(bucket); err != nil {
|
2017-06-21 22:53:09 -04:00
|
|
|
return pi, toObjectErr(err, bucket)
|
2017-01-16 20:05:00 -05:00
|
|
|
}
|
|
|
|
|
2017-10-06 12:38:01 -04:00
|
|
|
// Validate input data size and it can never be less than zero.
|
|
|
|
if data.Size() < 0 {
|
2017-11-25 14:58:29 -05:00
|
|
|
return pi, toObjectErr(errors.Trace(errInvalidArgument))
|
2017-10-06 12:38:01 -04:00
|
|
|
}
|
|
|
|
|
2017-01-16 20:05:00 -05:00
|
|
|
// Hold the lock so that two parallel complete-multipart-uploads
|
|
|
|
// do not leave a stale uploads.json behind.
|
|
|
|
objectMPartPathLock := globalNSMutex.NewNSLock(minioMetaMultipartBucket, pathJoin(bucket, object))
|
2017-08-31 14:29:22 -04:00
|
|
|
if err := objectMPartPathLock.GetLock(globalOperationTimeout); err != nil {
|
|
|
|
return pi, err
|
|
|
|
}
|
2017-01-16 20:05:00 -05:00
|
|
|
defer objectMPartPathLock.Unlock()
|
|
|
|
|
|
|
|
// Disallow any parallel abort or complete multipart operations.
|
|
|
|
uploadsPath := pathJoin(fs.fsPath, minioMetaMultipartBucket, bucket, object, uploadsJSONFile)
|
|
|
|
if _, err := fs.rwPool.Open(uploadsPath); err != nil {
|
|
|
|
if err == errFileNotFound || err == errFileAccessDenied {
|
2017-11-25 14:58:29 -05:00
|
|
|
return pi, errors.Trace(InvalidUploadID{UploadID: uploadID})
|
2017-01-16 20:05:00 -05:00
|
|
|
}
|
2017-11-25 14:58:29 -05:00
|
|
|
return pi, toObjectErr(errors.Trace(err), bucket, object)
|
2017-01-16 20:05:00 -05:00
|
|
|
}
|
|
|
|
defer fs.rwPool.Close(uploadsPath)
|
|
|
|
|
|
|
|
uploadIDPath := pathJoin(bucket, object, uploadID)
|
2016-06-02 18:19:13 -04:00
|
|
|
|
|
|
|
// Just check if the uploadID exists to avoid copy if it doesn't.
|
2017-01-16 20:05:00 -05:00
|
|
|
fsMetaPath := pathJoin(fs.fsPath, minioMetaMultipartBucket, uploadIDPath, fsMetaJSONFile)
|
|
|
|
rwlk, err := fs.rwPool.Write(fsMetaPath)
|
|
|
|
if err != nil {
|
|
|
|
if err == errFileNotFound || err == errFileAccessDenied {
|
2017-11-25 14:58:29 -05:00
|
|
|
return pi, errors.Trace(InvalidUploadID{UploadID: uploadID})
|
2017-01-16 20:05:00 -05:00
|
|
|
}
|
2017-11-25 14:58:29 -05:00
|
|
|
return pi, toObjectErr(errors.Trace(err), bucket, object)
|
2017-01-16 20:05:00 -05:00
|
|
|
}
|
|
|
|
defer rwlk.Close()
|
|
|
|
|
|
|
|
fsMeta := fsMetaV1{}
|
2017-01-25 15:29:06 -05:00
|
|
|
_, err = fsMeta.ReadFrom(rwlk)
|
2017-01-16 20:05:00 -05:00
|
|
|
if err != nil {
|
2017-06-21 22:53:09 -04:00
|
|
|
return pi, toObjectErr(err, minioMetaMultipartBucket, fsMetaPath)
|
2016-06-02 18:19:13 -04:00
|
|
|
}
|
|
|
|
|
2016-05-20 23:48:47 -04:00
|
|
|
partSuffix := fmt.Sprintf("object%d", partID)
|
2016-11-22 19:52:37 -05:00
|
|
|
tmpPartPath := uploadID + "." + mustGetUUID() + "." + partSuffix
|
2016-05-20 23:48:47 -04:00
|
|
|
|
2016-07-05 23:59:54 -04:00
|
|
|
bufSize := int64(readSizeV1)
|
2017-09-19 15:40:27 -04:00
|
|
|
if size := data.Size(); size > 0 && bufSize > size {
|
2016-07-05 23:59:54 -04:00
|
|
|
bufSize = size
|
|
|
|
}
|
2017-09-19 15:40:27 -04:00
|
|
|
buf := make([]byte, bufSize)
|
2016-10-29 15:44:44 -04:00
|
|
|
|
2017-01-16 20:05:00 -05:00
|
|
|
fsPartPath := pathJoin(fs.fsPath, minioMetaTmpBucket, fs.fsUUID, tmpPartPath)
|
2017-09-19 15:40:27 -04:00
|
|
|
bytesWritten, cErr := fsCreateFile(fsPartPath, data, buf, data.Size())
|
2016-07-18 22:06:48 -04:00
|
|
|
if cErr != nil {
|
2017-01-16 20:05:00 -05:00
|
|
|
fsRemoveFile(fsPartPath)
|
2017-06-21 22:53:09 -04:00
|
|
|
return pi, toObjectErr(cErr, minioMetaTmpBucket, tmpPartPath)
|
2016-07-18 22:06:48 -04:00
|
|
|
}
|
2016-12-03 14:53:12 -05:00
|
|
|
|
2016-07-18 22:06:48 -04:00
|
|
|
// Should return IncompleteBody{} error when reader has fewer
|
|
|
|
// bytes than specified in request header.
|
2017-09-19 15:40:27 -04:00
|
|
|
if bytesWritten < data.Size() {
|
2017-01-16 20:05:00 -05:00
|
|
|
fsRemoveFile(fsPartPath)
|
2017-11-25 14:58:29 -05:00
|
|
|
return pi, errors.Trace(IncompleteBody{})
|
2016-05-20 23:48:47 -04:00
|
|
|
}
|
|
|
|
|
2016-10-20 01:52:03 -04:00
|
|
|
// Delete temporary part in case of failure. If
|
|
|
|
// PutObjectPart succeeds then there would be nothing to
|
|
|
|
// delete.
|
2017-01-16 20:05:00 -05:00
|
|
|
defer fsRemoveFile(fsPartPath)
|
2016-10-20 01:52:03 -04:00
|
|
|
|
2017-01-16 20:05:00 -05:00
|
|
|
partPath := pathJoin(bucket, object, uploadID, partSuffix)
|
2016-11-23 15:50:09 -05:00
|
|
|
// Lock the part so that another part upload with same part-number gets blocked
|
|
|
|
// while the part is getting appended in the background.
|
2016-12-10 19:15:12 -05:00
|
|
|
partLock := globalNSMutex.NewNSLock(minioMetaMultipartBucket, partPath)
|
2017-08-31 14:29:22 -04:00
|
|
|
if err = partLock.GetLock(globalOperationTimeout); err != nil {
|
|
|
|
return pi, err
|
|
|
|
}
|
2017-01-16 20:05:00 -05:00
|
|
|
|
|
|
|
fsNSPartPath := pathJoin(fs.fsPath, minioMetaMultipartBucket, partPath)
|
|
|
|
if err = fsRenameFile(fsPartPath, fsNSPartPath); err != nil {
|
2016-11-23 15:50:09 -05:00
|
|
|
partLock.Unlock()
|
2017-06-21 22:53:09 -04:00
|
|
|
return pi, toObjectErr(err, minioMetaMultipartBucket, partPath)
|
2016-05-20 23:48:47 -04:00
|
|
|
}
|
2017-01-16 20:05:00 -05:00
|
|
|
|
2017-10-24 15:25:42 -04:00
|
|
|
md5hex := hex.EncodeToString(data.MD5Current())
|
2017-10-22 01:30:34 -04:00
|
|
|
|
2017-01-16 20:05:00 -05:00
|
|
|
// Save the object part info in `fs.json`.
|
2017-10-22 01:30:34 -04:00
|
|
|
fsMeta.AddObjectPart(partID, partSuffix, md5hex, data.Size())
|
2017-01-16 20:05:00 -05:00
|
|
|
if _, err = fsMeta.WriteTo(rwlk); err != nil {
|
2016-11-23 15:50:09 -05:00
|
|
|
partLock.Unlock()
|
2017-06-21 22:53:09 -04:00
|
|
|
return pi, toObjectErr(err, minioMetaMultipartBucket, uploadIDPath)
|
2017-01-31 12:38:34 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
partNamePath := pathJoin(fs.fsPath, minioMetaMultipartBucket, uploadIDPath, partSuffix)
|
|
|
|
fi, err := fsStatFile(partNamePath)
|
|
|
|
if err != nil {
|
2017-06-21 22:53:09 -04:00
|
|
|
return pi, toObjectErr(err, minioMetaMultipartBucket, partSuffix)
|
2016-05-20 23:48:47 -04:00
|
|
|
}
|
2016-11-21 02:42:53 -05:00
|
|
|
|
2016-12-09 19:10:18 -05:00
|
|
|
// Append the part in background.
|
2017-01-16 20:05:00 -05:00
|
|
|
errCh := fs.append(bucket, object, uploadID, fsMeta)
|
2016-11-23 15:50:09 -05:00
|
|
|
go func() {
|
2017-01-16 20:05:00 -05:00
|
|
|
// Also receive the error so that the appendParts go-routine
|
|
|
|
// does not block on send. But the error received is ignored
|
|
|
|
// as fs.PutObjectPart() would have already returned success
|
|
|
|
// to the client.
|
2016-11-23 15:50:09 -05:00
|
|
|
<-errCh
|
|
|
|
partLock.Unlock()
|
|
|
|
}()
|
2016-11-21 02:42:53 -05:00
|
|
|
|
2017-01-31 12:38:34 -05:00
|
|
|
return PartInfo{
|
|
|
|
PartNumber: partID,
|
|
|
|
LastModified: fi.ModTime(),
|
2017-10-22 01:30:34 -04:00
|
|
|
ETag: md5hex,
|
2017-01-31 12:38:34 -05:00
|
|
|
Size: fi.Size(),
|
|
|
|
}, nil
|
2016-05-20 23:48:47 -04:00
|
|
|
}
|
|
|
|
|
2017-10-05 19:08:25 -04:00
|
|
|
// listObjectParts - wrapper scanning through
|
|
|
|
// '.minio.sys/multipart/bucket/object/UPLOADID'. Lists all the parts
|
|
|
|
// saved inside '.minio.sys/multipart/bucket/object/UPLOADID'.
|
|
|
|
func (fs fsObjects) listObjectParts(bucket, object, uploadID string, partNumberMarker, maxParts int) (lpi ListPartsInfo, e error) {
|
|
|
|
result := ListPartsInfo{}
|
|
|
|
|
|
|
|
uploadIDPath := pathJoin(bucket, object, uploadID)
|
|
|
|
fsMetaPath := pathJoin(fs.fsPath, minioMetaMultipartBucket, uploadIDPath, fsMetaJSONFile)
|
|
|
|
metaFile, err := fs.rwPool.Open(fsMetaPath)
|
|
|
|
if err != nil {
|
|
|
|
if err == errFileNotFound || err == errFileAccessDenied {
|
|
|
|
// On windows oddly this is returned.
|
2017-11-25 14:58:29 -05:00
|
|
|
return lpi, errors.Trace(InvalidUploadID{UploadID: uploadID})
|
2017-10-05 19:08:25 -04:00
|
|
|
}
|
2017-11-25 14:58:29 -05:00
|
|
|
return lpi, toObjectErr(errors.Trace(err), bucket, object)
|
2017-10-05 19:08:25 -04:00
|
|
|
}
|
|
|
|
defer fs.rwPool.Close(fsMetaPath)
|
|
|
|
|
|
|
|
fsMeta := fsMetaV1{}
|
|
|
|
_, err = fsMeta.ReadFrom(metaFile.LockedFile)
|
|
|
|
if err != nil {
|
|
|
|
return lpi, toObjectErr(err, minioMetaBucket, fsMetaPath)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Only parts with higher part numbers will be listed.
|
|
|
|
partIdx := fsMeta.ObjectPartIndex(partNumberMarker)
|
|
|
|
parts := fsMeta.Parts
|
|
|
|
if partIdx != -1 {
|
|
|
|
parts = fsMeta.Parts[partIdx+1:]
|
|
|
|
}
|
|
|
|
|
|
|
|
count := maxParts
|
|
|
|
for _, part := range parts {
|
|
|
|
var fi os.FileInfo
|
|
|
|
partNamePath := pathJoin(fs.fsPath, minioMetaMultipartBucket, uploadIDPath, part.Name)
|
|
|
|
fi, err = fsStatFile(partNamePath)
|
|
|
|
if err != nil {
|
|
|
|
return lpi, toObjectErr(err, minioMetaMultipartBucket, partNamePath)
|
|
|
|
}
|
|
|
|
result.Parts = append(result.Parts, PartInfo{
|
|
|
|
PartNumber: part.Number,
|
|
|
|
ETag: part.ETag,
|
|
|
|
LastModified: fi.ModTime(),
|
|
|
|
Size: fi.Size(),
|
|
|
|
})
|
|
|
|
count--
|
|
|
|
if count == 0 {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If listed entries are more than maxParts, we set IsTruncated as true.
|
|
|
|
if len(parts) > len(result.Parts) {
|
|
|
|
result.IsTruncated = true
|
|
|
|
// Make sure to fill next part number marker if IsTruncated is
|
|
|
|
// true for subsequent listing.
|
|
|
|
nextPartNumberMarker := result.Parts[len(result.Parts)-1].PartNumber
|
|
|
|
result.NextPartNumberMarker = nextPartNumberMarker
|
|
|
|
}
|
|
|
|
result.Bucket = bucket
|
|
|
|
result.Object = object
|
|
|
|
result.UploadID = uploadID
|
|
|
|
result.MaxParts = maxParts
|
|
|
|
|
|
|
|
// Success.
|
|
|
|
return result, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ListObjectParts - lists all previously uploaded parts for a given
|
|
|
|
// object and uploadID. Takes additional input of part-number-marker
|
|
|
|
// to indicate where the listing should begin from.
|
|
|
|
//
|
|
|
|
// Implements S3 compatible ListObjectParts API. The resulting
|
|
|
|
// ListPartsInfo structure is unmarshalled directly into XML and
|
|
|
|
// replied back to the client.
|
2017-06-21 22:53:09 -04:00
|
|
|
func (fs fsObjects) ListObjectParts(bucket, object, uploadID string, partNumberMarker, maxParts int) (lpi ListPartsInfo, e error) {
|
2016-12-02 02:15:17 -05:00
|
|
|
if err := checkListPartsArgs(bucket, object, fs); err != nil {
|
2017-06-21 22:53:09 -04:00
|
|
|
return lpi, err
|
2016-06-02 15:18:56 -04:00
|
|
|
}
|
2016-08-31 14:39:08 -04:00
|
|
|
|
2017-08-04 13:45:57 -04:00
|
|
|
// Check if bucket exists
|
2017-01-16 20:05:00 -05:00
|
|
|
if _, err := fs.statBucketDir(bucket); err != nil {
|
2017-06-21 22:53:09 -04:00
|
|
|
return lpi, toObjectErr(err, bucket)
|
2016-05-03 19:10:24 -04:00
|
|
|
}
|
2016-05-20 23:48:47 -04:00
|
|
|
|
2017-10-05 19:08:25 -04:00
|
|
|
// Hold the lock so that two parallel complete-multipart-uploads
|
|
|
|
// do not leave a stale uploads.json behind.
|
|
|
|
objectMPartPathLock := globalNSMutex.NewNSLock(minioMetaMultipartBucket, pathJoin(bucket, object))
|
|
|
|
if err := objectMPartPathLock.GetRLock(globalListingTimeout); err != nil {
|
2017-11-25 14:58:29 -05:00
|
|
|
return lpi, errors.Trace(err)
|
2017-10-05 19:08:25 -04:00
|
|
|
}
|
|
|
|
defer objectMPartPathLock.RUnlock()
|
|
|
|
|
|
|
|
listPartsInfo, err := fs.listObjectParts(bucket, object, uploadID, partNumberMarker, maxParts)
|
2017-01-16 20:05:00 -05:00
|
|
|
if err != nil {
|
2017-10-05 19:08:25 -04:00
|
|
|
return lpi, toObjectErr(err, bucket, object)
|
2016-10-29 15:44:44 -04:00
|
|
|
}
|
2017-01-16 20:05:00 -05:00
|
|
|
|
2017-10-05 19:08:25 -04:00
|
|
|
return listPartsInfo, nil
|
2016-10-29 15:44:44 -04:00
|
|
|
}
|
|
|
|
|
2016-06-02 15:18:56 -04:00
|
|
|
// CompleteMultipartUpload - completes an ongoing multipart
|
|
|
|
// transaction after receiving all the parts indicated by the client.
|
|
|
|
// Returns an md5sum calculated by concatenating all the individual
|
|
|
|
// md5sums of all the parts.
|
|
|
|
//
|
|
|
|
// Implements S3 compatible Complete multipart API.
|
2017-11-14 03:25:10 -05:00
|
|
|
func (fs fsObjects) CompleteMultipartUpload(bucket string, object string, uploadID string, parts []CompletePart) (oi ObjectInfo, e error) {
|
2016-12-02 02:15:17 -05:00
|
|
|
if err := checkCompleteMultipartArgs(bucket, object, fs); err != nil {
|
2017-06-21 22:53:09 -04:00
|
|
|
return oi, err
|
2016-05-20 23:48:47 -04:00
|
|
|
}
|
2016-06-02 15:18:56 -04:00
|
|
|
|
2017-05-09 20:46:46 -04:00
|
|
|
// Check if an object is present as one of the parent dir.
|
|
|
|
if fs.parentDirIsObject(bucket, pathutil.Dir(object)) {
|
2017-11-25 14:58:29 -05:00
|
|
|
return oi, toObjectErr(errors.Trace(errFileAccessDenied), bucket, object)
|
2017-05-09 20:46:46 -04:00
|
|
|
}
|
|
|
|
|
2017-01-16 20:05:00 -05:00
|
|
|
if _, err := fs.statBucketDir(bucket); err != nil {
|
2017-06-21 22:53:09 -04:00
|
|
|
return oi, toObjectErr(err, bucket)
|
2016-05-20 23:48:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Calculate s3 compatible md5sum for complete multipart.
|
2016-11-10 10:41:02 -05:00
|
|
|
s3MD5, err := getCompleteMultipartMD5(parts)
|
2016-05-20 23:48:47 -04:00
|
|
|
if err != nil {
|
2017-06-21 22:53:09 -04:00
|
|
|
return oi, err
|
2016-05-20 23:48:47 -04:00
|
|
|
}
|
|
|
|
|
2017-01-16 20:05:00 -05:00
|
|
|
uploadIDPath := pathJoin(bucket, object, uploadID)
|
2017-09-28 11:09:28 -04:00
|
|
|
var removeObjectDir bool
|
2017-01-16 20:05:00 -05:00
|
|
|
|
|
|
|
// Hold the lock so that two parallel complete-multipart-uploads
|
|
|
|
// do not leave a stale uploads.json behind.
|
|
|
|
objectMPartPathLock := globalNSMutex.NewNSLock(minioMetaMultipartBucket, pathJoin(bucket, object))
|
2017-08-31 14:29:22 -04:00
|
|
|
if err = objectMPartPathLock.GetLock(globalOperationTimeout); err != nil {
|
|
|
|
return oi, err
|
|
|
|
}
|
2017-09-28 11:09:28 -04:00
|
|
|
|
|
|
|
defer func() {
|
|
|
|
if removeObjectDir {
|
|
|
|
basePath := pathJoin(fs.fsPath, minioMetaMultipartBucket, bucket)
|
|
|
|
derr := fsDeleteFile(basePath, pathJoin(basePath, object))
|
2017-11-25 14:58:29 -05:00
|
|
|
if derr = errors.Cause(derr); derr != nil {
|
2017-10-18 17:26:20 -04:00
|
|
|
// In parallel execution, CompleteMultipartUpload could have deleted temporary
|
|
|
|
// state files/directory, it is safe to ignore errFileNotFound
|
|
|
|
if derr != errFileNotFound {
|
|
|
|
errorIf(derr, "unable to remove %s in %s", pathJoin(basePath, object), basePath)
|
|
|
|
}
|
|
|
|
}
|
2017-09-28 11:09:28 -04:00
|
|
|
}
|
|
|
|
objectMPartPathLock.Unlock()
|
|
|
|
}()
|
2017-01-16 20:05:00 -05:00
|
|
|
|
|
|
|
fsMetaPathMultipart := pathJoin(fs.fsPath, minioMetaMultipartBucket, uploadIDPath, fsMetaJSONFile)
|
|
|
|
rlk, err := fs.rwPool.Open(fsMetaPathMultipart)
|
|
|
|
if err != nil {
|
|
|
|
if err == errFileNotFound || err == errFileAccessDenied {
|
2017-11-25 14:58:29 -05:00
|
|
|
return oi, errors.Trace(InvalidUploadID{UploadID: uploadID})
|
2017-01-16 20:05:00 -05:00
|
|
|
}
|
2017-11-25 14:58:29 -05:00
|
|
|
return oi, toObjectErr(errors.Trace(err), bucket, object)
|
2017-01-16 20:05:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// Disallow any parallel abort or complete multipart operations.
|
|
|
|
rwlk, err := fs.rwPool.Write(pathJoin(fs.fsPath, minioMetaMultipartBucket, bucket, object, uploadsJSONFile))
|
|
|
|
if err != nil {
|
|
|
|
fs.rwPool.Close(fsMetaPathMultipart)
|
|
|
|
if err == errFileNotFound || err == errFileAccessDenied {
|
2017-11-25 14:58:29 -05:00
|
|
|
return oi, errors.Trace(InvalidUploadID{UploadID: uploadID})
|
2017-01-16 20:05:00 -05:00
|
|
|
}
|
2017-11-25 14:58:29 -05:00
|
|
|
return oi, toObjectErr(errors.Trace(err), bucket, object)
|
2017-01-16 20:05:00 -05:00
|
|
|
}
|
|
|
|
defer rwlk.Close()
|
|
|
|
|
|
|
|
fsMeta := fsMetaV1{}
|
2016-08-31 16:42:57 -04:00
|
|
|
// Read saved fs metadata for ongoing multipart.
|
2017-01-25 15:29:06 -05:00
|
|
|
_, err = fsMeta.ReadFrom(rlk.LockedFile)
|
2016-08-31 16:42:57 -04:00
|
|
|
if err != nil {
|
2017-01-16 20:05:00 -05:00
|
|
|
fs.rwPool.Close(fsMetaPathMultipart)
|
2017-06-21 22:53:09 -04:00
|
|
|
return oi, toObjectErr(err, minioMetaMultipartBucket, fsMetaPathMultipart)
|
2016-08-31 16:42:57 -04:00
|
|
|
}
|
2016-05-20 23:48:47 -04:00
|
|
|
|
2017-10-17 15:01:28 -04:00
|
|
|
partSize := int64(-1) // Used later to ensure that all parts sizes are same.
|
2017-07-07 11:41:29 -04:00
|
|
|
// Validate all parts and then commit to disk.
|
|
|
|
for i, part := range parts {
|
|
|
|
partIdx := fsMeta.ObjectPartIndex(part.PartNumber)
|
|
|
|
if partIdx == -1 {
|
|
|
|
fs.rwPool.Close(fsMetaPathMultipart)
|
2017-11-25 14:58:29 -05:00
|
|
|
return oi, errors.Trace(InvalidPart{})
|
2017-07-07 11:41:29 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if fsMeta.Parts[partIdx].ETag != part.ETag {
|
|
|
|
fs.rwPool.Close(fsMetaPathMultipart)
|
2017-11-25 14:58:29 -05:00
|
|
|
return oi, errors.Trace(InvalidPart{})
|
2017-07-07 11:41:29 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// All parts except the last part has to be atleast 5MB.
|
|
|
|
if (i < len(parts)-1) && !isMinAllowedPartSize(fsMeta.Parts[partIdx].Size) {
|
|
|
|
fs.rwPool.Close(fsMetaPathMultipart)
|
2017-11-25 14:58:29 -05:00
|
|
|
return oi, errors.Trace(PartTooSmall{
|
2017-07-07 11:41:29 -04:00
|
|
|
PartNumber: part.PartNumber,
|
|
|
|
PartSize: fsMeta.Parts[partIdx].Size,
|
|
|
|
PartETag: part.ETag,
|
|
|
|
})
|
|
|
|
}
|
2017-10-17 15:01:28 -04:00
|
|
|
if partSize == -1 {
|
|
|
|
partSize = fsMeta.Parts[partIdx].Size
|
|
|
|
}
|
|
|
|
// TODO: Make necessary changes in future as explained in the below comment.
|
|
|
|
// All parts except the last part has to be of same size. We are introducing this
|
|
|
|
// check to see if any clients break. If clients do not break then we can optimize
|
|
|
|
// multipart PutObjectPart by writing the part at the right offset using pwrite()
|
|
|
|
// so that we don't need to do background append at all. i.e by the time we get
|
|
|
|
// CompleteMultipartUpload we already have the full file available which can be
|
|
|
|
// renamed to the main name-space.
|
|
|
|
if (i < len(parts)-1) && partSize != fsMeta.Parts[partIdx].Size {
|
|
|
|
fs.rwPool.Close(fsMetaPathMultipart)
|
2017-11-25 14:58:29 -05:00
|
|
|
return oi, errors.Trace(PartsSizeUnequal{})
|
2017-10-17 15:01:28 -04:00
|
|
|
}
|
2017-07-07 11:41:29 -04:00
|
|
|
}
|
|
|
|
|
2017-01-16 20:05:00 -05:00
|
|
|
// Wait for any competing PutObject() operation on bucket/object, since same namespace
|
|
|
|
// would be acquired for `fs.json`.
|
2017-06-12 20:40:28 -04:00
|
|
|
fsMetaPath := pathJoin(fs.fsPath, minioMetaBucket, bucketMetaPrefix, bucket, object, fsMetaJSONFile)
|
2017-01-16 20:05:00 -05:00
|
|
|
metaFile, err := fs.rwPool.Create(fsMetaPath)
|
|
|
|
if err != nil {
|
|
|
|
fs.rwPool.Close(fsMetaPathMultipart)
|
2017-11-25 14:58:29 -05:00
|
|
|
return oi, toObjectErr(errors.Trace(err), bucket, object)
|
2017-01-16 20:05:00 -05:00
|
|
|
}
|
|
|
|
defer metaFile.Close()
|
|
|
|
|
2017-01-16 22:23:43 -05:00
|
|
|
fsNSObjPath := pathJoin(fs.fsPath, bucket, object)
|
|
|
|
|
2016-11-30 02:26:36 -05:00
|
|
|
// This lock is held during rename of the appended tmp file to the actual
|
|
|
|
// location so that any competing GetObject/PutObject/DeleteObject do not race.
|
2016-11-23 06:04:04 -05:00
|
|
|
appendFallback := true // In case background-append did not append the required parts.
|
2017-01-16 20:05:00 -05:00
|
|
|
|
2016-11-21 02:42:53 -05:00
|
|
|
if isPartsSame(fsMeta.Parts, parts) {
|
2017-01-16 20:05:00 -05:00
|
|
|
err = fs.complete(bucket, object, uploadID, fsMeta)
|
2016-11-21 02:42:53 -05:00
|
|
|
if err == nil {
|
|
|
|
appendFallback = false
|
2017-01-16 20:05:00 -05:00
|
|
|
fsTmpObjPath := pathJoin(fs.fsPath, minioMetaTmpBucket, fs.fsUUID, uploadID)
|
|
|
|
if err = fsRenameFile(fsTmpObjPath, fsNSObjPath); err != nil {
|
|
|
|
fs.rwPool.Close(fsMetaPathMultipart)
|
2017-06-21 22:53:09 -04:00
|
|
|
return oi, toObjectErr(err, minioMetaTmpBucket, uploadID)
|
2016-11-21 02:42:53 -05:00
|
|
|
}
|
2016-05-20 23:48:47 -04:00
|
|
|
}
|
2016-11-21 02:42:53 -05:00
|
|
|
}
|
2016-11-01 03:56:03 -04:00
|
|
|
|
2016-11-21 02:42:53 -05:00
|
|
|
if appendFallback {
|
2016-11-23 06:04:04 -05:00
|
|
|
// background append could not do append all the required parts, hence we do it here.
|
|
|
|
tempObj := uploadID + "-" + "part.1"
|
2016-08-31 16:42:57 -04:00
|
|
|
|
2017-01-16 20:05:00 -05:00
|
|
|
fsTmpObjPath := pathJoin(fs.fsPath, minioMetaTmpBucket, fs.fsUUID, tempObj)
|
|
|
|
// Delete the temporary object in the case of a
|
|
|
|
// failure. If PutObject succeeds, then there would be
|
|
|
|
// nothing to delete.
|
|
|
|
defer fsRemoveFile(fsTmpObjPath)
|
|
|
|
|
2016-08-31 16:42:57 -04:00
|
|
|
// Allocate staging buffer.
|
|
|
|
var buf = make([]byte, readSizeV1)
|
2016-10-29 15:44:44 -04:00
|
|
|
|
2017-07-07 11:41:29 -04:00
|
|
|
for _, part := range parts {
|
2016-08-31 16:42:57 -04:00
|
|
|
// Construct part suffix.
|
|
|
|
partSuffix := fmt.Sprintf("object%d", part.PartNumber)
|
2017-01-16 20:05:00 -05:00
|
|
|
multipartPartFile := pathJoin(fs.fsPath, minioMetaMultipartBucket, uploadIDPath, partSuffix)
|
|
|
|
|
|
|
|
var reader io.ReadCloser
|
2017-02-24 12:20:40 -05:00
|
|
|
var offset int64
|
2017-01-16 20:05:00 -05:00
|
|
|
reader, _, err = fsOpenFile(multipartPartFile, offset)
|
|
|
|
if err != nil {
|
|
|
|
fs.rwPool.Close(fsMetaPathMultipart)
|
|
|
|
if err == errFileNotFound {
|
2017-11-25 14:58:29 -05:00
|
|
|
return oi, errors.Trace(InvalidPart{})
|
2016-05-28 18:13:15 -04:00
|
|
|
}
|
2017-11-25 14:58:29 -05:00
|
|
|
return oi, toObjectErr(errors.Trace(err), minioMetaMultipartBucket, partSuffix)
|
2016-05-20 23:48:47 -04:00
|
|
|
}
|
|
|
|
|
2017-01-16 20:05:00 -05:00
|
|
|
// No need to hold a lock, this is a unique file and will be only written
|
|
|
|
// to one one process per uploadID per minio process.
|
|
|
|
var wfile *os.File
|
2017-08-12 22:25:43 -04:00
|
|
|
wfile, err = os.OpenFile((fsTmpObjPath), os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0666)
|
2017-01-16 20:05:00 -05:00
|
|
|
if err != nil {
|
|
|
|
reader.Close()
|
|
|
|
fs.rwPool.Close(fsMetaPathMultipart)
|
2017-11-25 14:58:29 -05:00
|
|
|
return oi, toObjectErr(errors.Trace(err), bucket, object)
|
2016-08-31 16:42:57 -04:00
|
|
|
}
|
2017-01-16 20:05:00 -05:00
|
|
|
|
|
|
|
_, err = io.CopyBuffer(wfile, reader, buf)
|
|
|
|
if err != nil {
|
|
|
|
wfile.Close()
|
|
|
|
reader.Close()
|
|
|
|
fs.rwPool.Close(fsMetaPathMultipart)
|
2017-11-25 14:58:29 -05:00
|
|
|
return oi, toObjectErr(errors.Trace(err), bucket, object)
|
2017-01-16 20:05:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
wfile.Close()
|
|
|
|
reader.Close()
|
|
|
|
}
|
|
|
|
|
|
|
|
if err = fsRenameFile(fsTmpObjPath, fsNSObjPath); err != nil {
|
|
|
|
fs.rwPool.Close(fsMetaPathMultipart)
|
2017-06-21 22:53:09 -04:00
|
|
|
return oi, toObjectErr(err, minioMetaTmpBucket, uploadID)
|
2016-05-20 23:48:47 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-21 20:31:14 -04:00
|
|
|
// No need to save part info, since we have concatenated all parts.
|
|
|
|
fsMeta.Parts = nil
|
|
|
|
|
2016-11-11 19:36:07 -05:00
|
|
|
// Save additional metadata.
|
|
|
|
if len(fsMeta.Meta) == 0 {
|
|
|
|
fsMeta.Meta = make(map[string]string)
|
|
|
|
}
|
2017-05-14 15:05:51 -04:00
|
|
|
fsMeta.Meta["etag"] = s3MD5
|
2016-08-15 18:02:19 -04:00
|
|
|
|
2017-01-16 20:05:00 -05:00
|
|
|
// Write all the set metadata.
|
|
|
|
if _, err = fsMeta.WriteTo(metaFile); err != nil {
|
|
|
|
fs.rwPool.Close(fsMetaPathMultipart)
|
2017-06-21 22:53:09 -04:00
|
|
|
return oi, toObjectErr(err, bucket, object)
|
2016-07-21 20:31:14 -04:00
|
|
|
}
|
|
|
|
|
2017-01-16 20:05:00 -05:00
|
|
|
// Close lock held on bucket/object/uploadid/fs.json,
|
|
|
|
// this needs to be done for windows so that we can happily
|
|
|
|
// delete the bucket/object/uploadid
|
|
|
|
fs.rwPool.Close(fsMetaPathMultipart)
|
|
|
|
|
2016-05-20 23:48:47 -04:00
|
|
|
// Cleanup all the parts if everything else has been safely committed.
|
2017-01-16 20:05:00 -05:00
|
|
|
multipartObjectDir := pathJoin(fs.fsPath, minioMetaMultipartBucket, bucket, object)
|
|
|
|
multipartUploadIDDir := pathJoin(multipartObjectDir, uploadID)
|
|
|
|
if err = fsRemoveUploadIDPath(multipartObjectDir, multipartUploadIDDir); err != nil {
|
2017-06-21 22:53:09 -04:00
|
|
|
return oi, toObjectErr(err, bucket, object)
|
2016-05-20 23:48:47 -04:00
|
|
|
}
|
|
|
|
|
2017-01-16 20:05:00 -05:00
|
|
|
// Remove entry from `uploads.json`.
|
2017-09-28 11:09:28 -04:00
|
|
|
removeObjectDir, err = fs.removeUploadID(bucket, object, uploadID, rwlk)
|
|
|
|
if err != nil {
|
2017-06-21 22:53:09 -04:00
|
|
|
return oi, toObjectErr(err, minioMetaMultipartBucket, pathutil.Join(bucket, object))
|
2017-01-16 22:23:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fi, err := fsStatFile(fsNSObjPath)
|
|
|
|
if err != nil {
|
2017-06-21 22:53:09 -04:00
|
|
|
return oi, toObjectErr(err, bucket, object)
|
2016-06-02 18:54:00 -04:00
|
|
|
}
|
|
|
|
|
2017-01-16 22:23:43 -05:00
|
|
|
// Return object info.
|
|
|
|
return fsMeta.ToObjectInfo(bucket, object, fi), nil
|
2016-05-20 23:48:47 -04:00
|
|
|
}
|
|
|
|
|
2016-06-02 15:18:56 -04:00
|
|
|
// AbortMultipartUpload - aborts an ongoing multipart operation
|
|
|
|
// signified by the input uploadID. This is an atomic operation
|
|
|
|
// doesn't require clients to initiate multiple such requests.
|
|
|
|
//
|
|
|
|
// All parts are purged from all disks and reference to the uploadID
|
|
|
|
// would be removed from the system, rollback is not possible on this
|
|
|
|
// operation.
|
|
|
|
//
|
|
|
|
// Implements S3 compatible Abort multipart API, slight difference is
|
|
|
|
// that this is an atomic idempotent operation. Subsequent calls have
|
|
|
|
// no affect and further requests to the same uploadID would not be
|
|
|
|
// honored.
|
2016-05-20 23:48:47 -04:00
|
|
|
func (fs fsObjects) AbortMultipartUpload(bucket, object, uploadID string) error {
|
2016-12-02 02:15:17 -05:00
|
|
|
if err := checkAbortMultipartArgs(bucket, object, fs); err != nil {
|
|
|
|
return err
|
2016-06-02 15:18:56 -04:00
|
|
|
}
|
|
|
|
|
2017-01-16 20:05:00 -05:00
|
|
|
if _, err := fs.statBucketDir(bucket); err != nil {
|
|
|
|
return toObjectErr(err, bucket)
|
|
|
|
}
|
|
|
|
|
|
|
|
uploadIDPath := pathJoin(bucket, object, uploadID)
|
2017-09-28 11:09:28 -04:00
|
|
|
var removeObjectDir bool
|
2017-01-16 20:05:00 -05:00
|
|
|
|
|
|
|
// Hold the lock so that two parallel complete-multipart-uploads
|
|
|
|
// do not leave a stale uploads.json behind.
|
|
|
|
objectMPartPathLock := globalNSMutex.NewNSLock(minioMetaMultipartBucket,
|
|
|
|
pathJoin(bucket, object))
|
2017-08-31 14:29:22 -04:00
|
|
|
if err := objectMPartPathLock.GetLock(globalOperationTimeout); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-09-28 11:09:28 -04:00
|
|
|
|
|
|
|
defer func() {
|
|
|
|
if removeObjectDir {
|
|
|
|
basePath := pathJoin(fs.fsPath, minioMetaMultipartBucket, bucket)
|
|
|
|
derr := fsDeleteFile(basePath, pathJoin(basePath, object))
|
2017-11-25 14:58:29 -05:00
|
|
|
if derr = errors.Cause(derr); derr != nil {
|
2017-10-18 17:26:20 -04:00
|
|
|
// In parallel execution, AbortMultipartUpload could have deleted temporary
|
|
|
|
// state files/directory, it is safe to ignore errFileNotFound
|
|
|
|
if derr != errFileNotFound {
|
|
|
|
errorIf(derr, "unable to remove %s in %s", pathJoin(basePath, object), basePath)
|
|
|
|
}
|
|
|
|
}
|
2017-09-28 11:09:28 -04:00
|
|
|
}
|
|
|
|
objectMPartPathLock.Unlock()
|
|
|
|
}()
|
2017-01-16 20:05:00 -05:00
|
|
|
|
|
|
|
fsMetaPath := pathJoin(fs.fsPath, minioMetaMultipartBucket, uploadIDPath, fsMetaJSONFile)
|
|
|
|
if _, err := fs.rwPool.Open(fsMetaPath); err != nil {
|
|
|
|
if err == errFileNotFound || err == errFileAccessDenied {
|
2017-11-25 14:58:29 -05:00
|
|
|
return errors.Trace(InvalidUploadID{UploadID: uploadID})
|
2017-01-16 20:05:00 -05:00
|
|
|
}
|
2017-11-25 14:58:29 -05:00
|
|
|
return toObjectErr(errors.Trace(err), bucket, object)
|
2017-01-16 20:05:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
uploadsPath := pathJoin(bucket, object, uploadsJSONFile)
|
|
|
|
rwlk, err := fs.rwPool.Write(pathJoin(fs.fsPath, minioMetaMultipartBucket, uploadsPath))
|
|
|
|
if err != nil {
|
|
|
|
fs.rwPool.Close(fsMetaPath)
|
|
|
|
if err == errFileNotFound || err == errFileAccessDenied {
|
2017-11-25 14:58:29 -05:00
|
|
|
return errors.Trace(InvalidUploadID{UploadID: uploadID})
|
2017-01-16 20:05:00 -05:00
|
|
|
}
|
2017-11-25 14:58:29 -05:00
|
|
|
return toObjectErr(errors.Trace(err), bucket, object)
|
2017-01-16 20:05:00 -05:00
|
|
|
}
|
|
|
|
defer rwlk.Close()
|
|
|
|
|
|
|
|
// Signal appendParts routine to stop waiting for new parts to arrive.
|
|
|
|
fs.abort(uploadID)
|
|
|
|
|
|
|
|
// Close lock held on bucket/object/uploadid/fs.json,
|
|
|
|
// this needs to be done for windows so that we can happily
|
|
|
|
// delete the bucket/object/uploadid
|
|
|
|
fs.rwPool.Close(fsMetaPath)
|
|
|
|
|
|
|
|
// Cleanup all uploaded parts and abort the upload.
|
|
|
|
multipartObjectDir := pathJoin(fs.fsPath, minioMetaMultipartBucket, bucket, object)
|
|
|
|
multipartUploadIDDir := pathJoin(multipartObjectDir, uploadID)
|
|
|
|
if err = fsRemoveUploadIDPath(multipartObjectDir, multipartUploadIDDir); err != nil {
|
2017-01-26 18:40:10 -05:00
|
|
|
return toObjectErr(err, bucket, object)
|
2017-01-16 20:05:00 -05:00
|
|
|
}
|
2016-06-02 15:18:56 -04:00
|
|
|
|
2017-01-16 20:05:00 -05:00
|
|
|
// Remove entry from `uploads.json`.
|
2017-09-28 11:09:28 -04:00
|
|
|
removeObjectDir, err = fs.removeUploadID(bucket, object, uploadID, rwlk)
|
|
|
|
if err != nil {
|
2017-01-16 20:05:00 -05:00
|
|
|
return toObjectErr(err, bucket, object)
|
2016-06-02 15:18:56 -04:00
|
|
|
}
|
|
|
|
|
2017-01-16 20:05:00 -05:00
|
|
|
return nil
|
2016-05-02 19:57:31 -04:00
|
|
|
}
|