FS: Skip creating fs.json for objects created by minio (ex. policy.json) (#3353)

master
Krishna Srinivas 8 years ago committed by Harshavardhana
parent 46a6fde813
commit f3322e94c8
  1. 37
      cmd/fs-v1.go

@ -465,21 +465,20 @@ func (fs fsObjects) PutObject(bucket string, object string, size int64, data io.
return ObjectInfo{}, toObjectErr(traceError(err), bucket, object) return ObjectInfo{}, toObjectErr(traceError(err), bucket, object)
} }
// Save additional metadata. Initialize `fs.json` values. if bucket != minioMetaBucket {
fsMeta := newFSMetaV1() // Save objects' metadata in `fs.json`.
fsMeta.Meta = metadata // Skip creating fs.json if bucket is .minio.sys as the object would have been created
// by minio's S3 layer (ex. policy.json)
fsMetaPath := path.Join(bucketMetaPrefix, bucket, object, fsMetaJSONFile) fsMeta := newFSMetaV1()
if err = writeFSMetadata(fs.storage, minioMetaBucket, fsMetaPath, fsMeta); err != nil { fsMeta.Meta = metadata
return ObjectInfo{}, toObjectErr(traceError(err), bucket, object)
fsMetaPath := path.Join(bucketMetaPrefix, bucket, object, fsMetaJSONFile)
if err = writeFSMetadata(fs.storage, minioMetaBucket, fsMetaPath, fsMeta); err != nil {
return ObjectInfo{}, toObjectErr(traceError(err), bucket, object)
}
} }
objInfo, err = fs.getObjectInfo(bucket, object) return fs.getObjectInfo(bucket, object)
if err == nil {
// If MINIO_ENABLE_FSMETA is not enabled objInfo.MD5Sum will be empty.
objInfo.MD5Sum = newMD5Hex
}
return objInfo, err
} }
// DeleteObject - deletes an object from a bucket, this operation is destructive // DeleteObject - deletes an object from a bucket, this operation is destructive
@ -499,11 +498,15 @@ func (fs fsObjects) DeleteObject(bucket, object string) error {
objectLock.RLock() objectLock.RLock()
defer objectLock.RUnlock() defer objectLock.RUnlock()
err := fs.storage.DeleteFile(minioMetaBucket, path.Join(bucketMetaPrefix, bucket, object, fsMetaJSONFile)) if bucket != minioMetaBucket {
if err != nil && err != errFileNotFound { // We don't store fs.json for minio-S3-layer created files like policy.json,
return toObjectErr(traceError(err), bucket, object) // hence we don't try to delete fs.json for such files.
err := fs.storage.DeleteFile(minioMetaBucket, path.Join(bucketMetaPrefix, bucket, object, fsMetaJSONFile))
if err != nil && err != errFileNotFound {
return toObjectErr(traceError(err), bucket, object)
}
} }
if err = fs.storage.DeleteFile(bucket, object); err != nil { if err := fs.storage.DeleteFile(bucket, object); err != nil {
return toObjectErr(traceError(err), bucket, object) return toObjectErr(traceError(err), bucket, object)
} }
return nil return nil

Loading…
Cancel
Save