xl: Move format detection inside xl objects. (#1515)

Fixes #1449
This commit is contained in:
Harshavardhana
2016-05-07 00:59:43 -07:00
committed by Anand Babu (AB) Periasamy
parent a20ccb1e83
commit 434423de89
5 changed files with 112 additions and 115 deletions

View File

@@ -17,9 +17,7 @@
package main
import (
"fmt"
"net/http"
"reflect"
router "github.com/gorilla/mux"
)
@@ -38,26 +36,6 @@ func newObjectLayer(exportPaths ...string) (ObjectLayer, error) {
// configureServer handler returns final handler for the http server.
func configureServerHandler(srvCmdConfig serverCmdConfig) http.Handler {
// FIXME: currently we don't check single exportPath which uses FS layer.
if len(srvCmdConfig.exportPaths) > 1 {
if isFormatConfigFileExists() {
format, err := getFormatXL()
if err != nil {
fatalIf(err, "Failed to read format.json", nil)
}
if !reflect.DeepEqual(format.Disks, srvCmdConfig.exportPaths) {
err = fmt.Errorf("Number of export paths from command-line did not match the backend configuration. Backend is configured with [%s] exports.", format.Disks)
fatalIf(err, "", nil)
}
} else {
// First run: save disk configuration
if err := saveFormatXL(xlFormat{Version: "1", Disks: srvCmdConfig.exportPaths}); err != nil {
fatalIf(err, "Unable to save 'format.json'", nil)
}
}
}
objAPI, err := newObjectLayer(srvCmdConfig.exportPaths...)
fatalIf(err, "Initializing object layer failed.", nil)