diff options
author | alex-z <blackslayer4@gmail.com> | 2022-09-08 14:21:30 +0300 |
---|---|---|
committer | Matthieu Gallien <matthieu_gallien@yahoo.fr> | 2022-09-10 11:34:34 +0300 |
commit | 2a529eef3c317192765822c606f337a2ae0aca8d (patch) | |
tree | 5c04984ce99dddc38ebfdcfcb3640952fd99731c /src | |
parent | f0b9ecd7472a8e5a78d0a2ca0eb1c6a82eeaf9aa (diff) |
Make sure Folder is deleted from the list and the SyncJournalDB is closed for every folder of the account that has been removed.
Signed-off-by: alex-z <blackslayer4@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/common/syncjournaldb.cpp | 4 | ||||
-rw-r--r-- | src/gui/folder.cpp | 8 | ||||
-rw-r--r-- | src/gui/folder.h | 2 | ||||
-rw-r--r-- | src/gui/folderman.cpp | 16 | ||||
-rw-r--r-- | src/gui/folderman.h | 2 | ||||
-rw-r--r-- | src/gui/wizard/owncloudadvancedsetuppage.cpp | 2 |
6 files changed, 15 insertions, 19 deletions
diff --git a/src/common/syncjournaldb.cpp b/src/common/syncjournaldb.cpp index b5e4f97ca..a2caff63a 100644 --- a/src/common/syncjournaldb.cpp +++ b/src/common/syncjournaldb.cpp @@ -2425,7 +2425,9 @@ void SyncJournalDb::commitInternal(const QString &context, bool startTrans) SyncJournalDb::~SyncJournalDb() { - close(); + if (isOpen()) { + close(); + } } diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp index e76383150..7229c1ba4 100644 --- a/src/gui/folder.cpp +++ b/src/gui/folder.cpp @@ -302,14 +302,6 @@ void Folder::setSyncPaused(bool paused) emit canSyncChanged(); } -void Folder::onAssociatedAccountRemoved() -{ - if (_vfs) { - _vfs->stop(); - _vfs->unregisterFolder(); - } -} - void Folder::setSyncState(SyncResult::Status state) { _syncResult.setStatus(state); diff --git a/src/gui/folder.h b/src/gui/folder.h index 02134d907..87e4e7a4c 100644 --- a/src/gui/folder.h +++ b/src/gui/folder.h @@ -206,8 +206,6 @@ public: */ virtual void wipeForRemoval(); - void onAssociatedAccountRemoved(); - void setSyncState(SyncResult::Status state); void setDirtyNetworkLimits(); diff --git a/src/gui/folderman.cpp b/src/gui/folderman.cpp index 314b70917..97d4514d2 100644 --- a/src/gui/folderman.cpp +++ b/src/gui/folderman.cpp @@ -945,11 +945,15 @@ void FolderMan::runEtagJobIfPossible(Folder *folder) void FolderMan::slotAccountRemoved(AccountState *accountState) { + QVector<Folder *> foldersToRemove; for (const auto &folder : qAsConst(_folderMap)) { if (folder->accountState() == accountState) { - folder->onAssociatedAccountRemoved(); + foldersToRemove.push_back(folder); } } + for (const auto &folder : qAsConst(foldersToRemove)) { + removeFolder(folder); + } } void FolderMan::slotRemoveFoldersForAccount(AccountState *accountState) @@ -1663,10 +1667,10 @@ QPair<FolderMan::PathValidityResult, QString> FolderMan::checkPathValidityForNew { QPair<FolderMan::PathValidityResult, QString> result; - QString recursiveValidity = checkPathValidityRecursive(path); + const auto recursiveValidity = checkPathValidityRecursive(path); if (!recursiveValidity.isEmpty()) { qCDebug(lcFolderMan) << path << recursiveValidity; - result.first = FolderMan::ErrorRecursiveValidity; + result.first = FolderMan::PathValidityResult::ErrorRecursiveValidity; result.second = recursiveValidity; return result; } @@ -1684,7 +1688,7 @@ QPair<FolderMan::PathValidityResult, QString> FolderMan::checkPathValidityForNew bool differentPaths = QString::compare(folderDir, userDir, cs) != 0; if (differentPaths && folderDir.startsWith(userDir, cs)) { - result.first = FolderMan::ErrorContainsFolder; + result.first = FolderMan::PathValidityResult::ErrorContainsFolder; result.second = tr("The local folder %1 already contains a folder used in a folder sync connection. " "Please pick another one!") .arg(QDir::toNativeSeparators(path)); @@ -1692,7 +1696,7 @@ QPair<FolderMan::PathValidityResult, QString> FolderMan::checkPathValidityForNew } if (differentPaths && userDir.startsWith(folderDir, cs)) { - result.first = FolderMan::ErrorContainedInFolder; + result.first = FolderMan::PathValidityResult::ErrorContainedInFolder; result.second = tr("The local folder %1 is already contained in a folder used in a folder sync connection. " "Please pick another one!") .arg(QDir::toNativeSeparators(path)); @@ -1708,7 +1712,7 @@ QPair<FolderMan::PathValidityResult, QString> FolderMan::checkPathValidityForNew folderUrl.setUserName(user); if (serverUrl == folderUrl) { - result.first = FolderMan::ErrorNonEmptyFolder; + result.first = FolderMan::PathValidityResult::ErrorNonEmptyFolder; result.second = tr("There is already a sync from the server to this local folder. " "Please pick another local folder!"); return result; diff --git a/src/gui/folderman.h b/src/gui/folderman.h index 495138b67..985fcb50b 100644 --- a/src/gui/folderman.h +++ b/src/gui/folderman.h @@ -63,7 +63,7 @@ class FolderMan : public QObject { Q_OBJECT public: - enum PathValidityResult { + enum class PathValidityResult { Valid, ErrorRecursiveValidity, ErrorContainsFolder, diff --git a/src/gui/wizard/owncloudadvancedsetuppage.cpp b/src/gui/wizard/owncloudadvancedsetuppage.cpp index c050253ed..ccd54edc4 100644 --- a/src/gui/wizard/owncloudadvancedsetuppage.cpp +++ b/src/gui/wizard/owncloudadvancedsetuppage.cpp @@ -260,7 +260,7 @@ void OwncloudAdvancedSetupPage::updateStatus() // check if the local folder exists. If so, and if its not empty, show a warning. const auto pathValidityCheckResult = FolderMan::instance()->checkPathValidityForNewFolder(locFolder, serverUrl()); auto errorStr = pathValidityCheckResult.second; - _localFolderValid = errorStr.isEmpty() || pathValidityCheckResult.first == FolderMan::ErrorNonEmptyFolder; + _localFolderValid = errorStr.isEmpty() || pathValidityCheckResult.first == FolderMan::PathValidityResult::ErrorNonEmptyFolder; QString t; |