diff options
author | Hannah von Reth <hannah.vonreth@owncloud.com> | 2021-07-29 17:29:13 +0300 |
---|---|---|
committer | Hannah von Reth <vonreth@kde.org> | 2021-08-10 15:19:56 +0300 |
commit | 975b0f2c23daea9fbb1532b0a7a2e95e86b67e08 (patch) | |
tree | c58000fc8b12d5863cb5cb55969d465fcd3cd803 /src/gui/folderman.cpp | |
parent | d26c0540416c142aa8b63d45d129af6bb104820e (diff) |
Prevent using a sync folder for multiple accounts
Fixes: #8849
Diffstat (limited to 'src/gui/folderman.cpp')
-rw-r--r-- | src/gui/folderman.cpp | 29 |
1 files changed, 9 insertions, 20 deletions
diff --git a/src/gui/folderman.cpp b/src/gui/folderman.cpp index 609e2b0ff..a897cfe4c 100644 --- a/src/gui/folderman.cpp +++ b/src/gui/folderman.cpp @@ -1394,7 +1394,7 @@ static QString canonicalPath(const QString &path) return selFile.canonicalFilePath(); } -QString FolderMan::checkPathValidityForNewFolder(const QString &path, const QUrl &serverUrl) const +QString FolderMan::checkPathValidityForNewFolder(const QString &path) const { QString recursiveValidity = checkPathValidityRecursive(path); if (!recursiveValidity.isEmpty()) { @@ -1410,38 +1410,27 @@ QString FolderMan::checkPathValidityForNewFolder(const QString &path, const QUrl Folder *f = static_cast<Folder *>(i.value()); const QString folderDir = QDir::cleanPath(canonicalPath(f->path())) + '/'; - const bool differentPaths = QString::compare(folderDir, userDir, cs) != 0; - if (differentPaths && FileSystem::isChildPathOf(folderDir, userDir)) { + if (QString::compare(folderDir, userDir, cs) == 0) { + return tr("There is already a sync from the server to this local folder. " + "Please pick another local folder!"); + } + if (FileSystem::isChildPathOf(folderDir, userDir)) { return tr("The local folder %1 already contains a folder used in a folder sync connection. " "Please pick another one!") .arg(QDir::toNativeSeparators(path)); } - if (differentPaths && FileSystem::isChildPathOf(userDir, folderDir)) { + if (FileSystem::isChildPathOf(userDir, folderDir)) { return 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)); } - - // if both pathes are equal, the server url needs to be different - // otherwise it would mean that a new connection from the same local folder - // to the same account is added which is not wanted. The account must differ. - if (serverUrl.isValid() && !differentPaths) { - QUrl folderUrl = f->accountState()->account()->url(); - QString user = f->accountState()->account()->credentials()->user(); - folderUrl.setUserName(user); - - if (serverUrl == folderUrl) { - return tr("There is already a sync from the server to this local folder. " - "Please pick another local folder!"); - } - } } return QString(); } -QString FolderMan::findGoodPathForNewSyncFolder(const QString &basePath, const QUrl &serverUrl) const +QString FolderMan::findGoodPathForNewSyncFolder(const QString &basePath) const { QString folder = basePath; @@ -1460,7 +1449,7 @@ QString FolderMan::findGoodPathForNewSyncFolder(const QString &basePath, const Q forever { const bool isGood = !QFileInfo::exists(folder) - && FolderMan::instance()->checkPathValidityForNewFolder(folder, serverUrl).isEmpty(); + && FolderMan::instance()->checkPathValidityForNewFolder(folder).isEmpty(); if (isGood) { break; } |