Warn if we encounter an unsupported configuration
authorHannah von Reth <hannah.vonreth@owncloud.com>
Mon, 6 Sep 2021 12:13:01 +0000 (14:13 +0200)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Thu, 12 Dec 2024 13:27:48 +0000 (13:27 +0000)
src/gui/folderman.cpp
src/gui/folderman.h
src/gui/folderstatusmodel.cpp
src/gui/folderwizard.cpp

index 93e55952474d42c8f091b414afdf82322d322c63..fe44f591babc1d91934c7709333253b24e0176d7 100644 (file)
@@ -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 {
@@ -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();
@@ -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
index f0dafc4f211f7274f22399dc216cd4896d8450d8..ebfebb0b44359993ed858097092f5ca7ecaf114c 100644 (file)
@@ -234,6 +234,8 @@ public:
     /** 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.
index f712cf92cffdca368b16637e729d7c58f4b79262..44b2402c43c4f3aaab693a01b06ce7d1f97e0b79 100644 (file)
@@ -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."))
index d5a2225276e821368ee9ccb67960d6793daa3e4f..fe710af3dccdde90593ae09e12f5eb2830a928ed 100644 (file)
@@ -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) {