Commit 3287c36d authored by Sébastien Blin's avatar Sébastien Blin
Browse files

accounts: let the daemon removing accounts files

The daemon already flush the directory when removing accounts.
Moreover, getAccountsList() can fail and if it's the case, all
accounts are removed. This is dangerous!
Finally, when dbus fails, this can create dumb directories with
the error as a name. This patch avoid this case.

Change-Id: Ib74604f39adb9c2ba094c45a3f77a8d96ecb613c
parent 9734b125
......@@ -628,14 +628,6 @@ removeContact(Database& db, const std::string& contactUri)
}
}
void
removeAccount(const std::string& accountId)
{
auto accountLocalPath = getPath() + QString::fromStdString(accountId) + "/";
QDir dir(accountLocalPath);
dir.removeRecursively();
}
int
countUnreadFromInteractions(Database& db, const std::string& conversationId)
{
......
......@@ -312,13 +312,6 @@ void deleteObsoleteHistory(Database& db, long int date);
*/
void removeContact(Database& db, const std::string& contactUri);
/**
* Ensure that all files located in
* {local_storage}/jami/{accountId} are removed
* @param accountId
*/
void removeAccount(const std::string& accountId);
/**
* count number of 'UNREAD' from 'interactions' table.
* @param db
......
......@@ -381,7 +381,10 @@ NewAccountModelPimpl::updateAccounts()
// Detect new accounts
for (auto& id : accountIds) {
auto account = accounts.find(id.toStdString());
if (account == accounts.end()) {
// NOTE: If the daemon is down, but dbus answered, id can contains
// "Remote peer disconnected", "The name is not activable", etc.
// So avoid to create useless directories.
if (account == accounts.end() && id.indexOf(" ") == -1) {
qDebug("detected new account %s", id.toStdString().c_str());
addToAccounts(id.toStdString());
auto updatedAccount = accounts.find(id.toStdString());
......@@ -598,10 +601,6 @@ NewAccountModelPimpl::removeFromAccounts(const std::string& accountId)
return;
}
auto& accountInfo = account->second.first;
auto& accountDb = *(account->second.second);
accountDb.remove();
authority::storage::removeAccount(accountId);
/* Inform client about account removal. Do *not* free account structures
before we are sure that the client stopped using it, otherwise we might
get into use-after-free troubles. */
......
Supports Markdown
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