Browse Source

Merge pull request #1006 from AudriusButkevicius/defaults

Populate correct defaults
Jakob Borg 11 years ago
parent
commit
47b344ba12
3 changed files with 17 additions and 0 deletions
  1. 10 0
      internal/config/config.go
  2. 3 0
      internal/config/config_test.go
  3. 4 0
      internal/model/puller.go

+ 10 - 0
internal/config/config.go

@@ -335,10 +335,20 @@ func (cfg *Configuration) prepare(myID protocol.DeviceID) {
 	sort.Sort(DeviceConfigurationList(cfg.Devices))
 	// Ensure that any loose devices are not present in the wrong places
 	// Ensure that there are no duplicate devices
+	// Ensure that puller settings are sane
 	for i := range cfg.Folders {
 		cfg.Folders[i].Devices = ensureDevicePresent(cfg.Folders[i].Devices, myID)
 		cfg.Folders[i].Devices = ensureExistingDevices(cfg.Folders[i].Devices, existingDevices)
 		cfg.Folders[i].Devices = ensureNoDuplicates(cfg.Folders[i].Devices)
+		if cfg.Folders[i].Copiers == 0 {
+			cfg.Folders[i].Copiers = 1
+		}
+		if cfg.Folders[i].Pullers == 0 {
+			cfg.Folders[i].Pullers = 16
+		}
+		if cfg.Folders[i].Finishers == 0 {
+			cfg.Folders[i].Finishers = 1
+		}
 		sort.Sort(FolderDeviceConfigurationList(cfg.Folders[i].Devices))
 	}
 

+ 3 - 0
internal/config/config_test.go

@@ -85,6 +85,9 @@ func TestDeviceConfig(t *testing.T) {
 				Devices:         []FolderDeviceConfiguration{{DeviceID: device1}, {DeviceID: device4}},
 				ReadOnly:        true,
 				RescanIntervalS: 600,
+				Copiers:         1,
+				Pullers:         16,
+				Finishers:       1,
 			},
 		}
 		expectedDevices := []DeviceConfiguration{

+ 4 - 0
internal/model/puller.go

@@ -250,6 +250,10 @@ func (p *Puller) pullerIteration(checksum bool) int {
 	var pullWg sync.WaitGroup
 	var doneWg sync.WaitGroup
 
+	if debug {
+		l.Debugln(p, "c", p.copiers, "p", p.pullers, "f", p.finishers)
+	}
+
 	for i := 0; i < p.copiers; i++ {
 		copyWg.Add(1)
 		go func() {