lib/model, lib/config: Support "live" device removal, folder unsharing and folder configuration changes
Furthermore: 1. Cleans configs received, migrates them as we receive them. 2. Clears indexes of devices we no longer share the folder with GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3478
This commit is contained in:
@@ -435,10 +435,6 @@ func (s *Service) VerifyConfiguration(from, to config.Configuration) error {
|
||||
}
|
||||
|
||||
func (s *Service) CommitConfiguration(from, to config.Configuration) bool {
|
||||
// We require a restart if a device as been removed.
|
||||
|
||||
restart := false
|
||||
|
||||
newDevices := make(map[protocol.DeviceID]bool, len(to.Devices))
|
||||
for _, dev := range to.Devices {
|
||||
newDevices[dev.DeviceID] = true
|
||||
@@ -446,7 +442,12 @@ func (s *Service) CommitConfiguration(from, to config.Configuration) bool {
|
||||
|
||||
for _, dev := range from.Devices {
|
||||
if !newDevices[dev.DeviceID] {
|
||||
restart = true
|
||||
s.curConMut.Lock()
|
||||
delete(s.currentConnection, dev.DeviceID)
|
||||
s.curConMut.Unlock()
|
||||
warningLimitersMut.Lock()
|
||||
delete(warningLimiters, dev.DeviceID)
|
||||
warningLimitersMut.Unlock()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -498,7 +499,7 @@ func (s *Service) CommitConfiguration(from, to config.Configuration) bool {
|
||||
s.natServiceToken = nil
|
||||
}
|
||||
|
||||
return !restart
|
||||
return true
|
||||
}
|
||||
|
||||
func (s *Service) AllAddresses() []string {
|
||||
|
||||
Reference in New Issue
Block a user