From 262cf639564b074fa660535f5b08a8c577b7c632 Mon Sep 17 00:00:00 2001 From: Audrius Butkevicius Date: Sun, 23 Nov 2014 18:43:49 +0000 Subject: [PATCH] Populate correct defaults --- internal/config/config.go | 10 ++++++++++ internal/config/config_test.go | 3 +++ internal/model/puller.go | 4 ++++ 3 files changed, 17 insertions(+) diff --git a/internal/config/config.go b/internal/config/config.go index 355e1e216..6bc66b6a3 100644 --- a/internal/config/config.go +++ b/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)) } diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 85a85e431..ac779aafa 100644 --- a/internal/config/config_test.go +++ b/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{ diff --git a/internal/model/puller.go b/internal/model/puller.go index 0aa428d7c..807cef2aa 100644 --- a/internal/model/puller.go +++ b/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() {