Converge repeated code to common deleteBucketMetadata() (#5508)

master
Harshavardhana 7 years ago committed by kannappanr
parent 8de6cf4124
commit 91101b11bb
  1. 16
      cmd/fs-v1.go
  2. 19
      cmd/object-api-common.go
  3. 17
      cmd/xl-v1-bucket.go

@ -346,22 +346,10 @@ func (fs *fsObjects) DeleteBucket(bucket string) error {
if err = fsRemoveAll(minioMetadataBucketDir); err != nil { if err = fsRemoveAll(minioMetadataBucketDir); err != nil {
return toObjectErr(err, bucket) return toObjectErr(err, bucket)
} }
// Delete bucket access policy, if present - ignore any errors.
_ = removeBucketPolicy(bucket, fs)
// Notify all peers (including self) to update in-memory state // Delete all bucket metadata.
S3PeersUpdateBucketPolicy(bucket) deleteBucketMetadata(bucket, fs)
// Delete notification config, if present - ignore any errors.
_ = removeNotificationConfig(bucket, fs)
// Notify all peers (including self) to update in-memory state
S3PeersUpdateBucketNotification(bucket, nil)
// Delete listener config, if present - ignore any errors.
_ = removeListenerConfig(bucket, fs)
// Notify all peers (including self) to update in-memory state
S3PeersUpdateBucketListener(bucket, []listenerConfig{})
return nil return nil
} }

@ -85,6 +85,25 @@ func dirObjectInfo(bucket, object string, size int64, metadata map[string]string
} }
} }
func deleteBucketMetadata(bucket string, objAPI ObjectLayer) {
// Delete bucket access policy, if present - ignore any errors.
_ = removeBucketPolicy(bucket, objAPI)
// Notify all peers (including self) to update in-memory state
S3PeersUpdateBucketPolicy(bucket)
// Delete notification config, if present - ignore any errors.
_ = removeNotificationConfig(bucket, objAPI)
// Notify all peers (including self) to update in-memory state
S3PeersUpdateBucketNotification(bucket, nil)
// Delete listener config, if present - ignore any errors.
_ = removeListenerConfig(bucket, objAPI)
// Notify all peers (including self) to update in-memory state
S3PeersUpdateBucketListener(bucket, []listenerConfig{})
}
// House keeping code for FS/XL and distributed Minio setup. // House keeping code for FS/XL and distributed Minio setup.
func houseKeeping(storageDisks []StorageAPI) error { func houseKeeping(storageDisks []StorageAPI) error {
var wg = &sync.WaitGroup{} var wg = &sync.WaitGroup{}

@ -281,22 +281,9 @@ func (xl xlObjects) DeleteBucket(bucket string) error {
if err != nil { if err != nil {
return toObjectErr(err, bucket) return toObjectErr(err, bucket)
} }
// Delete bucket access policy, if present - ignore any errors.
_ = removeBucketPolicy(bucket, xl)
// Notify all peers (including self) to update in-memory state // Delete all bucket metadata.
S3PeersUpdateBucketPolicy(bucket) deleteBucketMetadata(bucket, xl)
// Delete notification config, if present - ignore any errors.
_ = removeNotificationConfig(bucket, xl)
// Notify all peers (including self) to update in-memory state
S3PeersUpdateBucketNotification(bucket, nil)
// Delete listener config, if present - ignore any errors.
_ = removeListenerConfig(bucket, xl)
// Notify all peers (including self) to update in-memory state
S3PeersUpdateBucketListener(bucket, []listenerConfig{})
return nil return nil
} }

Loading…
Cancel
Save