on switch to VFS real plugin, convert existing files to placeholders
authorMatthieu Gallien <matthieu.gallien@nextcloud.com>
Fri, 9 Jul 2021 10:23:41 +0000 (12:23 +0200)
committerFelix Weilbach <felix.weilbach@nextcloud.com>
Thu, 4 Nov 2021 14:02:27 +0000 (15:02 +0100)
Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
src/gui/folder.cpp
src/libsync/syncengine.cpp
src/libsync/syncengine.h

index 993dcb69e14a6c337a181813407f7e08a0346aab..3a33d45427d9bf70f647bd5bdb7ff9265b080651 100644 (file)
@@ -669,8 +669,10 @@ void Folder::setVirtualFilesEnabled(bool enabled)
 
         _definition.virtualFilesMode = newMode;
         startVfs();
-        if (newMode != Vfs::Off)
+        if (newMode != Vfs::Off) {
             _saveInFoldersWithPlaceholders = true;
+            SyncEngine::switchToVirtualFiles(path(), _journal, *_vfs);
+        }
         saveToSettings();
     }
 }
index 9813e63cb662f80a97668bf2933524b80f493368..47f24f832cfc546e93cc39f09f784c6e5de39c0a 100644 (file)
@@ -1019,6 +1019,16 @@ void SyncEngine::wipeVirtualFiles(const QString &localPath, SyncJournalDb &journ
     // But hydrated placeholders may still be around.
 }
 
+void SyncEngine::switchToVirtualFiles(const QString &localPath, SyncJournalDb &journal, Vfs &vfs)
+{
+    qCInfo(lcEngine) << "Convert to virtual files inside" << localPath;
+    journal.getFilesBelowPath({}, [&](const SyncJournalFileRecord &rec) {
+        SyncFileItem item;
+        QString localFile = localPath + rec.path();
+        vfs.convertToPlaceholder(localFile, item, localFile);
+    });
+}
+
 void SyncEngine::abort()
 {
     if (_propagator)
index 991ef48202ebed6e93cc5166ea1ceb1ad4d35bd4..9d0bada92df48d101901d09f464f0c06728df04d 100644 (file)
@@ -134,6 +134,8 @@ public:
      */
     static void wipeVirtualFiles(const QString &localPath, SyncJournalDb &journal, Vfs &vfs);
 
+    static void switchToVirtualFiles(const QString &localPath, SyncJournalDb &journal, Vfs &vfs);
+
     auto getPropagator() { return _propagator; } // for the test
 
 signals: