minio: Add config-folder option.

Fixes #997
This commit is contained in:
Harshavardhana
2015-12-06 14:31:20 -08:00
parent a97c4ebce3
commit 836f5204af
19 changed files with 149 additions and 202 deletions

View File

@@ -18,6 +18,7 @@ package fs
import (
"os"
"path/filepath"
"sync"
"time"
@@ -54,7 +55,10 @@ type Multiparts struct {
}
// New instantiate a new donut
func New() (Filesystem, *probe.Error) {
func New(rootPath string) (Filesystem, *probe.Error) {
setFSBucketsConfigPath(filepath.Join(rootPath, "$buckets.json"))
setFSMultipartsConfigPath(filepath.Join(rootPath, "$multiparts-session.json"))
var err *probe.Error
// load multiparts session from disk
var multiparts *Multiparts
@@ -65,7 +69,7 @@ func New() (Filesystem, *probe.Error) {
Version: "1",
ActiveSession: make(map[string]*MultipartSession),
}
if err := SaveMultipartsSession(multiparts); err != nil {
if err := saveMultipartsSession(multiparts); err != nil {
return Filesystem{}, err.Trace()
}
} else {
@@ -80,7 +84,7 @@ func New() (Filesystem, *probe.Error) {
Version: "1",
Metadata: make(map[string]*BucketMetadata),
}
if err := SaveBucketsMetadata(buckets); err != nil {
if err := saveBucketsMetadata(buckets); err != nil {
return Filesystem{}, err.Trace()
}
} else {
@@ -88,18 +92,12 @@ func New() (Filesystem, *probe.Error) {
}
}
a := Filesystem{lock: new(sync.Mutex)}
a.path = rootPath
a.multiparts = multiparts
a.buckets = buckets
return a, nil
}
// SetRootPath - set root path
func (fs *Filesystem) SetRootPath(path string) {
fs.lock.Lock()
defer fs.lock.Unlock()
fs.path = path
}
// SetMinFreeDisk - set min free disk
func (fs *Filesystem) SetMinFreeDisk(minFreeDisk int64) {
fs.lock.Lock()