Populate correct defaults

This commit is contained in:
Audrius Butkevicius 2014-11-23 18:43:49 +00:00
parent fe2ae4c6c3
commit 262cf63956
3 changed files with 17 additions and 0 deletions

View File

@ -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))
}

View File

@ -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{

View File

@ -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() {