From ac39dddc45a0ebf5ab36bebcdef91cf2c7c76294 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com>
Date: Fri, 17 Feb 2017 12:19:18 -0500
Subject: [PATCH] ringaccount: save device name after edit

After calling setAccountDetails with a new device name,
set the new device name in the device list
so the list is not overriten by loading the
device list from file.

Change-Id: Ie113e211fb7d0ace1c076122b1bc98ce6a49af08
Tuleap: #1494
---
 src/ringdht/ringaccount.cpp | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/ringdht/ringaccount.cpp b/src/ringdht/ringaccount.cpp
index f47e06f3df..4a9b7e6c2a 100644
--- a/src/ringdht/ringaccount.cpp
+++ b/src/ringdht/ringaccount.cpp
@@ -1517,12 +1517,20 @@ RingAccount::setAccountDetails(const std::map<std::string, std::string>& details
     parseString(details, DRing::Account::ConfProperties::RING_DEVICE_NAME, ringDeviceName_);
 
 #if HAVE_RINGNS
-    //std::string ringns_server;
     parseString(details, DRing::Account::ConfProperties::RingNS::URI,     nameServer_);
     nameDir_ = NameDirectory::instance(nameServer_);
 #endif
 
     loadAccount(archive_password, archive_pin);
+
+    // update device name if necessary
+    auto dev = knownDevices_.find(dht::InfoHash(ringDeviceId_));
+    if (dev != knownDevices_.end()) {
+        if (dev->second.name != ringDeviceName_) {
+            dev->second.name = ringDeviceName_;
+            saveKnownDevices();
+        }
+    }
 }
 
 std::map<std::string, std::string>
-- 
GitLab