From c2cf086bbd018fb6fe7bf9b6b8907aef29b59476 Mon Sep 17 00:00:00 2001 From: Ming Rui Zhang <mingrui.zhang@savoirfairelinux.com> Date: Thu, 8 Jul 2021 14:35:04 -0400 Subject: [PATCH] newaccountmodel: make account files to be cleared for account deletion 1. Close db when removing an account 2. Clear SIP account folder Change-Id: I1b8b26b5841528eb5a7315faed023051193277c3 --- src/newaccountmodel.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/newaccountmodel.cpp b/src/newaccountmodel.cpp index 4ce544cd..230c0967 100644 --- a/src/newaccountmodel.cpp +++ b/src/newaccountmodel.cpp @@ -320,6 +320,13 @@ NewAccountModel::exportOnRing(const QString& accountId, const QString& password) void NewAccountModel::removeAccount(const QString& accountId) const { + auto account = pimpl_->accounts.find(accountId); + if (account == pimpl_->accounts.end()) { + return; + } + + // Close db here for its removal + account->second.second->close(); ConfigurationManager::instance().removeAccount(accountId); } @@ -764,6 +771,11 @@ NewAccountModelPimpl::removeFromAccounts(const QString& accountId) return; } auto& accountInfo = account->second.first; + if (accountInfo.profileInfo.type == profile::Type::SIP) { + auto accountDir = QDir(authority::storage::getPath() + accountId); + accountDir.removeRecursively(); + } + /* 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. */ -- GitLab