Browse Source

Return a blank array instead of null if there are no repositories

Fixes a bug where it's impossible to add repositories in the web
interface if none are defined.
Veeti Paananen 11 years ago
parent
commit
85d5449b3c
1 changed files with 5 additions and 0 deletions
  1. 5 0
      cmd/syncthing/config.go

+ 5 - 0
cmd/syncthing/config.go

@@ -171,6 +171,11 @@ func readConfigXML(rd io.Reader, myID string) (Configuration, error) {
 
 	cfg.Options.ListenAddress = uniqueStrings(cfg.Options.ListenAddress)
 
+	// Initialize an empty slice for repositories if the config has none
+	if cfg.Repositories == nil {
+		cfg.Repositories = []RepositoryConfiguration{}
+	}
+
 	// Check for missing, bad or duplicate repository ID:s
 	var seenRepos = map[string]*RepositoryConfiguration{}
 	for i := range cfg.Repositories {