fs/bucket: Move bucket metadata into buckets.json

This commit is contained in:
Harshavardhana
2015-11-01 20:56:54 -08:00
parent 38aa7e1678
commit ab15f56a61
7 changed files with 165 additions and 74 deletions

View File

@@ -30,6 +30,13 @@ type Filesystem struct {
minFreeDisk int64
lock *sync.Mutex
multiparts *Multiparts
buckets *Buckets
}
// Buckets holds acl information
type Buckets struct {
Version string `json:"version"`
Metadata map[string]*BucketMetadata
}
// MultipartSession holds active session information
@@ -65,8 +72,24 @@ func New() (Filesystem, *probe.Error) {
return Filesystem{}, err.Trace()
}
}
var buckets *Buckets
buckets, err = loadBucketsMetadata()
if err != nil {
if os.IsNotExist(err.ToGoError()) {
buckets = &Buckets{
Version: "1",
Metadata: make(map[string]*BucketMetadata),
}
if err := SaveBucketsMetadata(buckets); err != nil {
return Filesystem{}, err.Trace()
}
} else {
return Filesystem{}, err.Trace()
}
}
a := Filesystem{lock: new(sync.Mutex)}
a.multiparts = multiparts
a.buckets = buckets
return a, nil
}