lib/model: Use up to date device name, do not provide name to unknown devices (fixes #4164)

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4168
This commit is contained in:
Audrius Butkevicius
2017-05-22 19:58:33 +00:00
parent 51518490c6
commit 91d37f35bc
7 changed files with 47 additions and 43 deletions

View File

@@ -157,7 +157,8 @@ type Configuration struct {
IgnoredDevices []protocol.DeviceID `xml:"ignoredDevice" json:"ignoredDevices"`
XMLName xml.Name `xml:"configuration" json:"-"`
OriginalVersion int `xml:"-" json:"-"` // The version we read from disk, before any conversion
MyID protocol.DeviceID `xml:"-" json:"-"` // Provided by the instantiator.
OriginalVersion int `xml:"-" json:"-"` // The version we read from disk, before any conversion
}
func (cfg Configuration) Copy() Configuration {
@@ -198,6 +199,8 @@ func (cfg *Configuration) WriteXML(w io.Writer) error {
func (cfg *Configuration) prepare(myID protocol.DeviceID) error {
var myName string
cfg.MyID = myID
// Ensure this device is present in the config
for _, device := range cfg.Devices {
if device.DeviceID == myID {