Commit 5bfa1288 authored by Sébastien Blin's avatar Sébastien Blin

dbus: ignore invalid answer from daemon

Change-Id: Ie548b6c7f536cf673f0df1b0a11bb793cff11adc
parent 5433aa52
......@@ -605,6 +605,14 @@ LegacyDatabase::migrateLocalProfiles()
const QStringList accountIds = ConfigurationManager::instance().getAccountList();
for (auto accountId : accountIds) {
// NOTE: If the daemon is down, but dbus answered, id can contains
// "Remote peer disconnected", "The name is not activable", etc.
// So avoid to migrate useless directories.
for (auto& id : accountIds)
if (id.indexOf(" ") != -1) {
qWarning() << "Invalid dbus answer. Daemon not running";
return;
}
MapStringString account = ConfigurationManager::instance().
getAccountDetails(accountId.toStdString().c_str());
auto accountURI = account[DRing::Account::ConfProperties::USERNAME].contains("ring:") ?
......@@ -847,9 +855,16 @@ LegacyDatabase::migrateSchemaFromVersion1()
void
LegacyDatabase::linkRingProfilesWithAccounts(bool contactsOnly)
{
const QStringList accountIds =
ConfigurationManager::instance().getAccountList();
const QStringList accountIds = ConfigurationManager::instance().getAccountList();
for (auto accountId : accountIds) {
// NOTE: If the daemon is down, but dbus answered, id can contains
// "Remote peer disconnected", "The name is not activable", etc.
// So avoid to migrate useless directories.
for (auto& id : accountIds)
if (id.indexOf(" ") != -1) {
qWarning() << "Invalid dbus answer. Daemon not running";
return;
}
MapStringString account = ConfigurationManager::instance().
getAccountDetails(accountId.toStdString().c_str());
auto accountURI = account[DRing::Account::ConfProperties::USERNAME].contains("ring:") ?
......
......@@ -339,6 +339,16 @@ NewAccountModelPimpl::NewAccountModelPimpl(NewAccountModel& linked,
, username_changed(false)
{
const QStringList accountIds = ConfigurationManager::instance().getAccountList();
// NOTE: If the daemon is down, but dbus answered, id can contains
// "Remote peer disconnected", "The name is not activable", etc.
// So avoid to migrate useless directories.
for (auto& id : accountIds)
if (id.indexOf(" ") != -1) {
qWarning() << "Invalid dbus answer. Daemon not running";
return;
}
auto accountDbs = authority::storage::migrateIfNeeded(accountIds, willMigrateCb, didMigrateCb);
for (const auto& id : accountIds) {
addToAccounts(id.toStdString(), accountDbs.at(accountIds.indexOf(id)));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment