xl/fs: isFunctions should only return boolean. (#1525)

log the unrecognize errors.
This commit is contained in:
Harshavardhana
2016-05-08 01:58:05 -07:00
committed by Anand Babu (AB) Periasamy
parent 937d68202d
commit a56d5ef415
9 changed files with 113 additions and 90 deletions

View File

@@ -139,6 +139,9 @@ func (xl xlObjects) GetObject(bucket, object string, startOffset int64) (io.Read
if !IsValidBucketName(bucket) {
return nil, BucketNameInvalid{Bucket: bucket}
}
if !isBucketExist(xl.storage, bucket) {
return nil, BucketNotFound{Bucket: bucket}
}
// Verify if object is valid.
if !IsValidObjectName(object) {
return nil, ObjectNameInvalid{Bucket: bucket, Object: object}
@@ -201,16 +204,14 @@ func (xl xlObjects) GetObjectInfo(bucket, object string) (ObjectInfo, error) {
if !IsValidBucketName(bucket) {
return ObjectInfo{}, BucketNameInvalid{Bucket: bucket}
}
// Check whether the bucket exists.
if !isBucketExist(xl.storage, bucket) {
return ObjectInfo{}, BucketNotFound{Bucket: bucket}
}
// Verify if object is valid.
if !IsValidObjectName(object) {
return ObjectInfo{}, ObjectNameInvalid{Bucket: bucket, Object: object}
}
// Check whether the bucket exists.
if isExist, err := isBucketExist(xl.storage, bucket); err != nil {
return ObjectInfo{}, err
} else if !isExist {
return ObjectInfo{}, BucketNotFound{Bucket: bucket}
}
fi, err := xl.storage.StatFile(bucket, object)
if err != nil {
if err != errFileNotFound {
@@ -265,6 +266,9 @@ func (xl xlObjects) DeleteObject(bucket, object string) error {
if !IsValidBucketName(bucket) {
return BucketNameInvalid{Bucket: bucket}
}
if !isBucketExist(xl.storage, bucket) {
return BucketNotFound{Bucket: bucket}
}
if !IsValidObjectName(object) {
return ObjectNameInvalid{Bucket: bucket, Object: object}
}