Skip to content

Commit 1b5925c

Browse files
committed
Warn if we encounter an unsupported configuration
1 parent b4f61d0 commit 1b5925c

File tree

3 files changed

+32
-5
lines changed

3 files changed

+32
-5
lines changed

src/gui/folderman.cpp

+21-3
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,16 @@
3636
#include <QSet>
3737
#include <QNetworkProxy>
3838

39-
static const char versionC[] = "version";
40-
static const int maxFoldersVersion = 1;
39+
namespace {
40+
const char versionC[] = "version";
41+
const int maxFoldersVersion = 1;
42+
43+
int numberOfSyncJournals(const QString &path)
44+
{
45+
return QDir(path).entryList({ QStringLiteral(".sync_*.db"), QStringLiteral("._sync_*.db") }, QDir::Hidden | QDir::Files).size();
46+
}
47+
48+
}
4149

4250
namespace OCC {
4351
Q_LOGGING_CATEGORY(lcFolderMan, "gui.folder.manager", QtInfoMsg)
@@ -1331,7 +1339,7 @@ static QString checkPathValidityRecursive(const QString &path)
13311339
Utility::NtfsPermissionLookupRAII ntfs_perm;
13321340
#endif
13331341
const QFileInfo selFile(path);
1334-
if (!QDir(path).entryList({ QStringLiteral(".sync_*.db"), QStringLiteral("._sync_*.db") }, QDir::Hidden | QDir::Files).isEmpty()) {
1342+
if (numberOfSyncJournals(selFile.filePath()) != 0) {
13351343
return FolderMan::tr("The folder %1 is used in a folder sync connection!").arg(QDir::toNativeSeparators(selFile.filePath()));
13361344
}
13371345

@@ -1474,5 +1482,15 @@ void FolderMan::restartApplication()
14741482
}
14751483
}
14761484

1485+
Result<void, QString> FolderMan::unsupportedConfiguration(const QString &path) const
1486+
{
1487+
if (numberOfSyncJournals(path) > 1) {
1488+
return tr("Multiple accounts are sharing the folder %1.\n"
1489+
"This configuration is know to lead to dataloss and is no longer supported.\n"
1490+
"Please consider removing this folder from the account and adding it again.")
1491+
.arg(path);
1492+
}
1493+
return {};
1494+
}
14771495

14781496
} // namespace OCC

src/gui/folderman.h

+2
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ class FolderMan : public QObject
239239
void setDirtyProxy();
240240
void setDirtyNetworkLimits();
241241

242+
/** If the folder configuration is no longer supported this will return an error string */
243+
Result<void, QString> unsupportedConfiguration(const QString &path) const;
242244
signals:
243245
/**
244246
* signal to indicate a folder has changed its sync state.

src/gui/folderstatusmodel.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,15 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const
207207
return (f->syncResult().hasUnresolvedConflicts())
208208
? QStringList(tr("There are unresolved conflicts. Click for details."))
209209
: QStringList();
210-
case FolderStatusDelegate::FolderErrorMsg:
211-
return f->syncResult().errorStrings();
210+
case FolderStatusDelegate::FolderErrorMsg: {
211+
auto errors = f->syncResult().errorStrings();
212+
const auto legacyError = FolderMan::instance()->unsupportedConfiguration(f->path());
213+
if (!legacyError) {
214+
// the error message might contain new lines, the delegate only expect multiple single line values
215+
errors.append(legacyError.error().split(QLatin1Char('\n')));
216+
}
217+
return errors;
218+
}
212219
case FolderStatusDelegate::FolderInfoMsg:
213220
return f->virtualFilesEnabled() && f->vfs().mode() != Vfs::Mode::WindowsCfApi
214221
? QStringList(tr("Virtual file support is enabled."))

0 commit comments

Comments
 (0)