mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-09 23:00:58 +00:00
parent
493de9392a
commit
8d67235a75
@ -95,10 +95,9 @@ type wrapper struct {
|
|||||||
path string
|
path string
|
||||||
evLogger events.Logger
|
evLogger events.Logger
|
||||||
|
|
||||||
waiter Waiter // Latest ongoing config change
|
waiter Waiter // Latest ongoing config change
|
||||||
deviceMap map[protocol.DeviceID]DeviceConfiguration
|
subs []Committer
|
||||||
subs []Committer
|
mut sync.Mutex
|
||||||
mut sync.Mutex
|
|
||||||
|
|
||||||
requiresRestart uint32 // an atomic bool
|
requiresRestart uint32 // an atomic bool
|
||||||
}
|
}
|
||||||
@ -195,7 +194,6 @@ func (w *wrapper) replaceLocked(to Configuration) (Waiter, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
w.cfg = to
|
w.cfg = to
|
||||||
w.deviceMap = nil
|
|
||||||
|
|
||||||
w.waiter = w.notifyListeners(from.Copy(), to.Copy())
|
w.waiter = w.notifyListeners(from.Copy(), to.Copy())
|
||||||
|
|
||||||
@ -226,13 +224,11 @@ func (w *wrapper) notifyListener(sub Committer, from, to Configuration) {
|
|||||||
func (w *wrapper) Devices() map[protocol.DeviceID]DeviceConfiguration {
|
func (w *wrapper) Devices() map[protocol.DeviceID]DeviceConfiguration {
|
||||||
w.mut.Lock()
|
w.mut.Lock()
|
||||||
defer w.mut.Unlock()
|
defer w.mut.Unlock()
|
||||||
if w.deviceMap == nil {
|
deviceMap := make(map[protocol.DeviceID]DeviceConfiguration, len(w.cfg.Devices))
|
||||||
w.deviceMap = make(map[protocol.DeviceID]DeviceConfiguration, len(w.cfg.Devices))
|
for _, dev := range w.cfg.Devices {
|
||||||
for _, dev := range w.cfg.Devices {
|
deviceMap[dev.DeviceID] = dev.Copy()
|
||||||
w.deviceMap[dev.DeviceID] = dev.Copy()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return w.deviceMap
|
return deviceMap
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetDevices adds new devices to the configuration, or overwrites existing
|
// SetDevices adds new devices to the configuration, or overwrites existing
|
||||||
|
Loading…
Reference in New Issue
Block a user