xl/fs: Add initObjectLayer function. (#1494)

Fixes #1493
master
Harshavardhana 9 years ago committed by Anand Babu (AB) Periasamy
parent 658a595d7a
commit ca097de96c
  1. 5
      fs-objects.go
  2. 27
      object-common.go
  3. 5
      xl-objects.go

@ -52,8 +52,9 @@ func newFSObjects(exportPath string) (ObjectLayer, error) {
} }
} }
// Cleanup all temp entries upon start. // Initialize object layer - like creating minioMetaBucket,
cleanupAllTmpEntries(storage) // cleaning up tmp files etc.
initObjectLayer(storage)
// Return successfully initialized object layer. // Return successfully initialized object layer.
return fsObjects{ return fsObjects{

@ -24,6 +24,24 @@ import (
"sort" "sort"
) )
// Common initialization needed for both object layers.
func initObjectLayer(storage StorageAPI) error {
// This happens for the first time, but keep this here since this
// is the only place where it can be made expensive optimizing all
// other calls. Create minio meta volume, if it doesn't exist yet.
if err := storage.MakeVol(minioMetaBucket); err != nil {
if err != errVolumeExists {
return toObjectErr(err, minioMetaBucket)
}
}
// Cleanup all temp entries upon start.
err := cleanupAllTmpEntries(storage)
if err != nil {
return toObjectErr(err, minioMetaBucket, tmpMetaPrefix)
}
return nil
}
/// Common object layer functions. /// Common object layer functions.
// makeBucket - create a bucket, is a common function for both object layers. // makeBucket - create a bucket, is a common function for both object layers.
@ -35,15 +53,6 @@ func makeBucket(storage StorageAPI, bucket string) error {
if err := storage.MakeVol(bucket); err != nil { if err := storage.MakeVol(bucket); err != nil {
return toObjectErr(err, bucket) return toObjectErr(err, bucket)
} }
// This happens for the first time, but keep this here since this
// is the only place where it can be made expensive optimizing all
// other calls.
// Create minio meta volume, if it doesn't exist yet.
if err := storage.MakeVol(minioMetaBucket); err != nil {
if err != errVolumeExists {
return toObjectErr(err, minioMetaBucket)
}
}
return nil return nil
} }

@ -53,8 +53,9 @@ func newXLObjects(exportPaths ...string) (ObjectLayer, error) {
return nil, err return nil, err
} }
// Cleanup all temporary entries. // Initialize object layer - like creating minioMetaBucket,
cleanupAllTmpEntries(storage) // cleaning up tmp files etc.
initObjectLayer(storage)
// Return successfully initialized object layer. // Return successfully initialized object layer.
return xlObjects{ return xlObjects{

Loading…
Cancel
Save