Skip to content

Commit

Permalink
Warn if we encounter an unsupported configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
TheOneRing authored and camilasan committed Dec 2, 2024
1 parent a5900ae commit 24870d0
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
21 changes: 21 additions & 0 deletions src/gui/folderman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ constexpr auto settingsAccountsC = "Accounts";
constexpr auto settingsFoldersC = "Folders";
constexpr auto settingsVersionC = "version";
constexpr auto maxFoldersVersion = 1;
const char versionC[] = "version";

int numberOfSyncJournals(const QString &path)
{
return QDir(path).entryList({ QStringLiteral(".sync_*.db"), QStringLiteral("._sync_*.db") }, QDir::Hidden | QDir::Files).size();
}

}

namespace OCC {
Expand Down Expand Up @@ -1800,6 +1807,9 @@ static QString checkPathValidityRecursive(const QString &path)
Utility::NtfsPermissionLookupRAII ntfs_perm;
#endif
const QFileInfo selFile(path);
if (numberOfSyncJournals(selFile.filePath()) != 0) {
return FolderMan::tr("The folder %1 is used in a folder sync connection!").arg(QDir::toNativeSeparators(selFile.filePath()));
}

if (!FileSystem::fileExists(path)) {
QString parentPath = selFile.dir().path();
Expand Down Expand Up @@ -2032,4 +2042,15 @@ bool FolderMan::checkVfsAvailability(const QString &path, Vfs::Mode mode) const
return unsupportedConfiguration(path) && Vfs::checkAvailability(path, mode);
}

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
2 changes: 2 additions & 0 deletions src/gui/folderman.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ class FolderMan : public QObject
/** Whether or not vfs is supported in the location. */
bool checkVfsAvailability(const QString &path, Vfs::Mode mode = bestAvailableVfsMode()) const;

/** 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.
Expand Down
11 changes: 9 additions & 2 deletions src/gui/folderstatusmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,15 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const
return (folder->syncResult().hasUnresolvedConflicts())
? QStringList(tr("There are unresolved conflicts. Click for details."))
: QStringList();
case FolderStatusDelegate::FolderErrorMsg:
return folder->syncResult().errorStrings();
case FolderStatusDelegate::FolderErrorMsg: {
auto errors = folder->syncResult().errorStrings();
const auto legacyError = FolderMan::instance()->unsupportedConfiguration(folder->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 folder->virtualFilesEnabled() && folder->vfs().mode() != Vfs::Mode::WindowsCfApi
? QStringList(tr("Virtual file support is enabled."))
Expand Down
2 changes: 1 addition & 1 deletion src/gui/folderwizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ void FolderWizardSelectiveSync::initializePage()
bool FolderWizardSelectiveSync::validatePage()
{
const auto mode = bestAvailableVfsMode();
const bool useVirtualFiles = (Theme::instance()->forceVirtualFilesOption() && mode == Vfs::WindowsCfApi) || (_virtualFilesCheckBox && _virtualFilesCheckBox->isChecked());
const bool useVirtualFiles = (mode == Vfs::WindowsCfApi) || (_virtualFilesCheckBox && _virtualFilesCheckBox->isChecked());
if (useVirtualFiles) {
const auto availability = Vfs::checkAvailability(wizard()->field(QStringLiteral("sourceFolder")).toString(), mode);
if (!availability) {
Expand Down

0 comments on commit 24870d0

Please sign in to comment.