Fix FS remove bucket regression bug (#2693)

This commit is contained in:
Anis Elleuch 2016-09-15 00:41:39 +01:00 committed by Harshavardhana
parent 19e01ceb19
commit a84548d7ea
3 changed files with 9 additions and 9 deletions

View File

@ -117,26 +117,24 @@ func (fs fsObjects) Shutdown() error {
_, err := fs.storage.ListDir(minioMetaBucket, mpartMetaPrefix)
if err != errFileNotFound {
// A nil err means that multipart directory is not empty hence do not remove '.minio.sys' volume.
// A non nil err means that an unexpected error occurred
return err
// A non nil err means that an unexpected error occured
return toObjectErr(traceError(err))
}
// List if there are any bucket configuration entries.
_, err = fs.storage.ListDir(minioMetaBucket, bucketConfigPrefix)
if err != errFileNotFound {
// A nil err means that bucket config directory is not empty hence do not remove '.minio.sys' volume.
// A non nil err means that an unexpected error occurred
return err
// A non nil err means that an unexpected error occured
return toObjectErr(traceError(err))
}
// Cleanup everything else.
prefix := ""
if err = cleanupDir(fs.storage, minioMetaBucket, prefix); err != nil {
errorIf(err, "Unable to cleanup minio meta bucket")
return err
}
if err = fs.storage.DeleteVol(minioMetaBucket); err != nil {
if err != errVolumeNotEmpty {
errorIf(err, "Unable to delete minio meta bucket %s", minioMetaBucket)
return err
return toObjectErr(traceError(err))
}
}
// Successful.
@ -220,7 +218,7 @@ func (fs fsObjects) DeleteBucket(bucket string) error {
return toObjectErr(traceError(err), bucket)
}
// Cleanup all the previously incomplete multiparts.
if err := cleanupDir(fs.storage, path.Join(minioMetaBucket, mpartMetaPrefix), bucket); err != nil && err != errVolumeNotFound {
if err := cleanupDir(fs.storage, path.Join(minioMetaBucket, mpartMetaPrefix), bucket); err != nil && errorCause(err) != errVolumeNotFound {
return toObjectErr(err, bucket)
}
return nil

View File

@ -216,7 +216,8 @@ func cleanupDir(storage StorageAPI, volume, dirPath string) error {
delFunc = func(entryPath string) error {
if !strings.HasSuffix(entryPath, slashSeparator) {
// Delete the file entry.
return storage.DeleteFile(volume, entryPath)
err := storage.DeleteFile(volume, entryPath)
return traceError(err)
}
// If it's a directory, list and call delFunc() for each entry.

View File

@ -62,6 +62,7 @@ func newObjectLayer(disks, ignoredDisks []string) (ObjectLayer, error) {
globalShutdownCBs.AddObjectLayerCB(func() errCode {
if objAPI != nil {
if sErr := objAPI.Shutdown(); sErr != nil {
errorIf(err, "Unable to shutdown object API.")
return exitFailure
}
}