mirror of
https://github.com/pgsty/minio.git
synced 2026-08-07 08:11:13 +03:00
Add updateConfig code to load config changes if possible for every function
This commit is contained in:
+29
-10
@@ -38,6 +38,9 @@ import (
|
||||
func (donut API) NewMultipartUpload(bucket, key, contentType string) (string, error) {
|
||||
donut.lock.Lock()
|
||||
defer donut.lock.Unlock()
|
||||
// update Config if possible
|
||||
donut.updateConfig()
|
||||
|
||||
if !IsValidBucket(bucket) {
|
||||
return "", iodine.New(BucketNameInvalid{Bucket: bucket}, nil)
|
||||
}
|
||||
@@ -69,6 +72,9 @@ func (donut API) NewMultipartUpload(bucket, key, contentType string) (string, er
|
||||
func (donut API) AbortMultipartUpload(bucket, key, uploadID string) error {
|
||||
donut.lock.Lock()
|
||||
defer donut.lock.Unlock()
|
||||
// update Config if possible
|
||||
donut.updateConfig()
|
||||
|
||||
if !IsValidBucket(bucket) {
|
||||
return iodine.New(BucketNameInvalid{Bucket: bucket}, nil)
|
||||
}
|
||||
@@ -85,6 +91,20 @@ func (donut API) AbortMultipartUpload(bucket, key, uploadID string) error {
|
||||
|
||||
// CreateObjectPart - create a part in a multipart session
|
||||
func (donut API) CreateObjectPart(bucket, key, uploadID string, partID int, contentType, expectedMD5Sum string, size int64, data io.Reader) (string, error) {
|
||||
donut.lock.Lock()
|
||||
defer donut.lock.Unlock()
|
||||
// update Config if possible
|
||||
donut.updateConfig()
|
||||
|
||||
etag, err := donut.createObjectPart(bucket, key, uploadID, partID, "", expectedMD5Sum, size, data)
|
||||
// possible free
|
||||
debug.FreeOSMemory()
|
||||
|
||||
return etag, iodine.New(err, nil)
|
||||
}
|
||||
|
||||
// createObject - internal wrapper function called by CreateObjectPart
|
||||
func (donut API) createObjectPart(bucket, key, uploadID string, partID int, contentType, expectedMD5Sum string, size int64, data io.Reader) (string, error) {
|
||||
if !IsValidBucket(bucket) {
|
||||
return "", iodine.New(BucketNameInvalid{Bucket: bucket}, nil)
|
||||
}
|
||||
@@ -94,16 +114,6 @@ func (donut API) CreateObjectPart(bucket, key, uploadID string, partID int, cont
|
||||
if !donut.storedBuckets.Exists(bucket) {
|
||||
return "", iodine.New(BucketNotFound{Bucket: bucket}, nil)
|
||||
}
|
||||
donut.lock.Lock()
|
||||
etag, err := donut.createObjectPart(bucket, key, uploadID, partID, "", expectedMD5Sum, size, data)
|
||||
donut.lock.Unlock()
|
||||
// possible free
|
||||
debug.FreeOSMemory()
|
||||
return etag, iodine.New(err, nil)
|
||||
}
|
||||
|
||||
// createObject - internal wrapper function called by CreateObjectPart
|
||||
func (donut API) createObjectPart(bucket, key, uploadID string, partID int, contentType, expectedMD5Sum string, size int64, data io.Reader) (string, error) {
|
||||
storedBucket := donut.storedBuckets.Get(bucket).(storedBucket)
|
||||
// Verify upload id
|
||||
if storedBucket.multiPartSession[key].uploadID != uploadID {
|
||||
@@ -191,6 +201,9 @@ func (donut API) cleanupMultipartSession(bucket, key, uploadID string) {
|
||||
// CompleteMultipartUpload - complete a multipart upload and persist the data
|
||||
func (donut API) CompleteMultipartUpload(bucket, key, uploadID string, parts map[int]string) (ObjectMetadata, error) {
|
||||
donut.lock.Lock()
|
||||
// update Config if possible
|
||||
donut.updateConfig()
|
||||
|
||||
if !IsValidBucket(bucket) {
|
||||
donut.lock.Unlock()
|
||||
return ObjectMetadata{}, iodine.New(BucketNameInvalid{Bucket: bucket}, nil)
|
||||
@@ -269,6 +282,9 @@ func (donut API) ListMultipartUploads(bucket string, resources BucketMultipartRe
|
||||
// TODO handle delimiter
|
||||
donut.lock.Lock()
|
||||
defer donut.lock.Unlock()
|
||||
// update Config if possible
|
||||
donut.updateConfig()
|
||||
|
||||
if !donut.storedBuckets.Exists(bucket) {
|
||||
return BucketMultipartResourcesMetadata{}, iodine.New(BucketNotFound{Bucket: bucket}, nil)
|
||||
}
|
||||
@@ -331,6 +347,9 @@ func (donut API) ListObjectParts(bucket, key string, resources ObjectResourcesMe
|
||||
// Verify upload id
|
||||
donut.lock.Lock()
|
||||
defer donut.lock.Unlock()
|
||||
// update Config if possible
|
||||
donut.updateConfig()
|
||||
|
||||
if !donut.storedBuckets.Exists(bucket) {
|
||||
return ObjectResourcesMetadata{}, iodine.New(BucketNotFound{Bucket: bucket}, nil)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user