mirror of
https://github.com/octoleo/syncthing.git
synced 2025-02-02 11:58:28 +00:00
Merge branch 'pr-840'
* pr-840: More descriptive error if config couldn't be loaded Better handling of wrong config files
This commit is contained in:
commit
244a22755c
@ -346,13 +346,20 @@ func syncthingMain() {
|
|||||||
// Load the configuration file, if it exists.
|
// Load the configuration file, if it exists.
|
||||||
// If it does not, create a template.
|
// If it does not, create a template.
|
||||||
|
|
||||||
cfg, err = config.Load(cfgFile, myID)
|
if info, err := os.Stat(cfgFile); err == nil {
|
||||||
if err == nil {
|
if !info.Mode().IsRegular() {
|
||||||
myCfg := cfg.Devices()[myID]
|
l.Fatalln("Config file is not a file?")
|
||||||
if myCfg.Name == "" {
|
}
|
||||||
myName, _ = os.Hostname()
|
cfg, err = config.Load(cfgFile, myID)
|
||||||
|
if err == nil {
|
||||||
|
myCfg := cfg.Devices()[myID]
|
||||||
|
if myCfg.Name == "" {
|
||||||
|
myName, _ = os.Hostname()
|
||||||
|
} else {
|
||||||
|
myName = myCfg.Name
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
myName = myCfg.Name
|
l.Fatalln("Configuration:", err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
l.Infoln("No config file; starting with empty defaults")
|
l.Infoln("No config file; starting with empty defaults")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user