@ -20,7 +20,6 @@ import (
"bytes"
"bytes"
"context"
"context"
"encoding/json"
"encoding/json"
"os"
"path"
"path"
"runtime"
"runtime"
"strings"
"strings"
@ -160,16 +159,19 @@ func initConfig(objAPI ObjectLayer) error {
if globalEtcdClient != nil {
if globalEtcdClient != nil {
if err := checkConfigEtcd ( context . Background ( ) , globalEtcdClient , getConfigFile ( ) ) ; err != nil {
if err := checkConfigEtcd ( context . Background ( ) , globalEtcdClient , getConfigFile ( ) ) ; err != nil {
return err
if err == errConfigNotFound {
}
// Migrates all configs at old location.
// Migrates all configs at old location.
if err : = migrateConfig ( ) ; err != nil {
if err = migrateConfig ( ) ; err != nil {
return err
return err
}
}
// Migrates etcd ${HOME}/.minio/config.json to '/config/config.json'
// Migrates etcd ${HOME}/.minio/config.json to '/config/config.json'
if err : = migrateConfigToMinioSys ( objAPI ) ; err != nil {
if err = migrateConfigToMinioSys ( objAPI ) ; err != nil {
return err
return err
}
}
} else {
return err
}
}
} else {
} else {
if isFile ( getConfigFile ( ) ) {
if isFile ( getConfigFile ( ) ) {
if err := migrateConfig ( ) ; err != nil {
if err := migrateConfig ( ) ; err != nil {
@ -179,7 +181,7 @@ func initConfig(objAPI ObjectLayer) error {
// Migrates ${HOME}/.minio/config.json or config.json.deprecated
// Migrates ${HOME}/.minio/config.json or config.json.deprecated
// to '<export_path>/.minio.sys/config/config.json'
// to '<export_path>/.minio.sys/config/config.json'
// ignore if the file doesn't exist.
// ignore if the file doesn't exist.
if err := migrateConfigToMinioSys ( objAPI ) ; err != nil && ! os . IsNotExist ( err ) {
if err := migrateConfigToMinioSys ( objAPI ) ; err != nil {
return err
return err
}
}
}
}
@ -189,17 +191,6 @@ func initConfig(objAPI ObjectLayer) error {
// Watch config for changes and reloads them in-memory.
// Watch config for changes and reloads them in-memory.
go watchConfig ( objAPI , configFile , loadConfig )
go watchConfig ( objAPI , configFile , loadConfig )
if err := checkConfig ( context . Background ( ) , objAPI , configFile ) ; err != nil {
if err == errConfigNotFound {
// Config file does not exist, we create it fresh and return upon success.
if err = newSrvConfig ( objAPI ) ; err != nil {
return err
}
} else {
return err
}
}
if err := migrateMinioSysConfig ( objAPI ) ; err != nil {
if err := migrateMinioSysConfig ( objAPI ) ; err != nil {
return err
return err
}
}