Check if peer name change before update labels (#658)

This commit is contained in:
Maycon Santos 2023-01-20 10:07:37 +01:00 committed by GitHub
parent 5e3502bb83
commit 4406d50c18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -201,20 +201,21 @@ func (am *DefaultAccountManager) UpdatePeer(accountID string, update *Peer) (*Pe
return nil, err
}
if peer.Name != "" {
peer.Name = update.Name
}
peer.SSHEnabled = update.SSHEnabled
existingLabels := account.getPeerDNSLabels()
if peer.Name != update.Name {
peer.Name = update.Name
newLabel, err := getPeerHostLabel(peer.Name, existingLabels)
if err != nil {
return nil, err
existingLabels := account.getPeerDNSLabels()
newLabel, err := getPeerHostLabel(peer.Name, existingLabels)
if err != nil {
return nil, err
}
peer.DNSLabel = newLabel
}
peer.DNSLabel = newLabel
account.UpdatePeer(peer)
err = am.Store.SaveAccount(account)