Explorar o código

Don't start when the config dir is not a dir

Jakob Borg %!s(int64=11) %!d(string=hai) anos
pai
achega
9ff04ee3d8
Modificáronse 1 ficheiros con 6 adicións e 2 borrados
  1. 6 2
      cmd/syncthing/main.go

+ 6 - 2
cmd/syncthing/main.go

@@ -248,6 +248,12 @@ func main() {
 		return
 	}
 
+	confDir = expandTilde(confDir)
+
+	if info, err := os.Stat(confDir); err == nil && !info.IsDir() {
+		l.Fatalln("Config directory", confDir, "is not a directory")
+	}
+
 	if os.Getenv("STNORESTART") != "" {
 		syncthingMain()
 	} else {
@@ -266,8 +272,6 @@ func syncthingMain() {
 		runtime.GOMAXPROCS(runtime.NumCPU())
 	}
 
-	confDir = expandTilde(confDir)
-
 	events.Default.Log(events.Starting, map[string]string{"home": confDir})
 
 	if _, err = os.Stat(confDir); err != nil && confDir == getDefaultConfDir() {