diff options
author | Hannah von Reth <hannah.vonreth@owncloud.com> | 2021-09-06 15:13:01 +0300 |
---|---|---|
committer | Hannah von Reth <vonreth@kde.org> | 2021-09-06 16:44:06 +0300 |
commit | 1b5925c327c01bbff65de4059d1153c9d6574ba9 (patch) | |
tree | 69250ddfb5938f1995cd7d94daf63769cae86eb3 | |
parent | b4f61d0ba844286a45bc93bd5cf797944f8941d9 (diff) |
Warn if we encounter an unsupported configuration
-rw-r--r-- | src/gui/folderman.cpp | 24 | ||||
-rw-r--r-- | src/gui/folderman.h | 2 | ||||
-rw-r--r-- | src/gui/folderstatusmodel.cpp | 11 |
3 files changed, 32 insertions, 5 deletions
diff --git a/src/gui/folderman.cpp b/src/gui/folderman.cpp index 652085f9d..8de0ec6fc 100644 --- a/src/gui/folderman.cpp +++ b/src/gui/folderman.cpp @@ -36,8 +36,16 @@ #include <QSet> #include <QNetworkProxy> -static const char versionC[] = "version"; -static const int maxFoldersVersion = 1; +namespace { +const char versionC[] = "version"; +const int maxFoldersVersion = 1; + +int numberOfSyncJournals(const QString &path) +{ + return QDir(path).entryList({ QStringLiteral(".sync_*.db"), QStringLiteral("._sync_*.db") }, QDir::Hidden | QDir::Files).size(); +} + +} namespace OCC { Q_LOGGING_CATEGORY(lcFolderMan, "gui.folder.manager", QtInfoMsg) @@ -1331,7 +1339,7 @@ static QString checkPathValidityRecursive(const QString &path) Utility::NtfsPermissionLookupRAII ntfs_perm; #endif const QFileInfo selFile(path); - if (!QDir(path).entryList({ QStringLiteral(".sync_*.db"), QStringLiteral("._sync_*.db") }, QDir::Hidden | QDir::Files).isEmpty()) { + if (numberOfSyncJournals(selFile.filePath()) != 0) { return FolderMan::tr("The folder %1 is used in a folder sync connection!").arg(QDir::toNativeSeparators(selFile.filePath())); } @@ -1474,5 +1482,15 @@ void FolderMan::restartApplication() } } +Result<void, QString> FolderMan::unsupportedConfiguration(const QString &path) const +{ + if (numberOfSyncJournals(path) > 1) { + return tr("Multiple accounts are sharing the folder %1.\n" + "This configuration is know to lead to dataloss and is no longer supported.\n" + "Please consider removing this folder from the account and adding it again.") + .arg(path); + } + return {}; +} } // namespace OCC diff --git a/src/gui/folderman.h b/src/gui/folderman.h index bb60bf142..bf0720445 100644 --- a/src/gui/folderman.h +++ b/src/gui/folderman.h @@ -239,6 +239,8 @@ public: void setDirtyProxy(); void setDirtyNetworkLimits(); + /** If the folder configuration is no longer supported this will return an error string */ + Result<void, QString> unsupportedConfiguration(const QString &path) const; signals: /** * signal to indicate a folder has changed its sync state. diff --git a/src/gui/folderstatusmodel.cpp b/src/gui/folderstatusmodel.cpp index 8f4449bcf..f0d9d1373 100644 --- a/src/gui/folderstatusmodel.cpp +++ b/src/gui/folderstatusmodel.cpp @@ -207,8 +207,15 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const return (f->syncResult().hasUnresolvedConflicts()) ? QStringList(tr("There are unresolved conflicts. Click for details.")) : QStringList(); - case FolderStatusDelegate::FolderErrorMsg: - return f->syncResult().errorStrings(); + case FolderStatusDelegate::FolderErrorMsg: { + auto errors = f->syncResult().errorStrings(); + const auto legacyError = FolderMan::instance()->unsupportedConfiguration(f->path()); + if (!legacyError) { + // the error message might contain new lines, the delegate only expect multiple single line values + errors.append(legacyError.error().split(QLatin1Char('\n'))); + } + return errors; + } case FolderStatusDelegate::FolderInfoMsg: return f->virtualFilesEnabled() && f->vfs().mode() != Vfs::Mode::WindowsCfApi ? QStringList(tr("Virtual file support is enabled.")) |