Vfs: Ensure older versions gracefully ignore winvfs folders
authorChristian Kamm <mail@ckamm.de>
Tue, 18 Dec 2018 09:47:45 +0000 (10:47 +0100)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 15 Dec 2020 09:58:28 +0000 (10:58 +0100)
Previously there'd likely be a mess if a 2.6 winvfs folder was attempted
to be used with a 2.5 client. Now the older clients will ignore these
folders.

src/gui/folder.cpp
src/gui/folder.h

index 107e8644f257fa3e5243d1c8da1c31a6bc3b75bc..cca99b8f8a27b5c91a74d2fe8bf0e2b19f5efad9 100644 (file)
@@ -1247,11 +1247,16 @@ void FolderDefinition::save(QSettings &settings, const FolderDefinition &folder)
     settings.setValue(QLatin1String("targetPath"), folder.targetPath);
     settings.setValue(QLatin1String("paused"), folder.paused);
     settings.setValue(QLatin1String("ignoreHiddenFiles"), folder.ignoreHiddenFiles);
-    settings.setValue(QLatin1String(versionC), maxSettingsVersion());
     settings.setValue(QLatin1String("usePlaceholders"), folder.newFilesAreVirtual);
 
     settings.setValue(QStringLiteral("virtualFilesMode"), Vfs::modeToString(folder.virtualFilesMode));
 
+    // Ensure new vfs modes won't be attempted by older clients
+    if (folder.virtualFilesMode == Vfs::WindowsCfApi) {
+        settings.setValue(QLatin1String(versionC), 3);
+    } else {
+        settings.setValue(QLatin1String(versionC), 2);
+    }
 
     // Happens only on Windows when the explorer integration is enabled.
     if (!folder.navigationPaneClsid.isNull())
index c8d37da1ab069db60a85c5669600eb63db69860f..978fa6144d205a514e21904f6bab977ad146be9d 100644 (file)
@@ -78,8 +78,14 @@ public:
     static bool load(QSettings &settings, const QString &alias,
         FolderDefinition *folder);
 
-    /// The highest version in the settings that load() can read
-    static int maxSettingsVersion() { return 2; }
+    /** The highest version in the settings that load() can read
+     *
+     * Version 1: initial version (default if value absent in settings)
+     * Version 2: introduction of metadata_parent hash in 2.6.0
+     *            (version remains readable by 2.5.1)
+     * Version 3: introduction of new windows vfs mode in 2.6.0
+     */
+    static int maxSettingsVersion() { return 3; }
 
     /// Ensure / as separator and trailing /.
     static QString prepareLocalPath(const QString &path);