diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp index 6668cce2736..4dee481699a 100644 --- a/src/gui/folder.cpp +++ b/src/gui/folder.cpp @@ -769,10 +769,16 @@ void Folder::setVirtualFilesEnabled(bool enabled) } if (newMode != _definition.virtualFilesMode) { + // This is tested in TestSyncVirtualFiles::testWipeVirtualSuffixFiles, so for changes here, have them reflected in that test. + // TODO: Must wait for current sync to finish! OC_ENFORCE(!isSyncRunning()); + + // Wipe the dehydrated files from the DB, they will get downloaded on the next sync. We need to do this, otherwise the files + // are in the DB but not on disk, so the client assumes they are deleted, and removes them from the remote. _vfs->wipeDehydratedVirtualFiles(); + // Tear down the VFS _vfs->stop(); _vfs->unregisterFolder(); @@ -782,6 +788,7 @@ void Folder::setVirtualFilesEnabled(bool enabled) _vfsIsReady = false; _vfs.reset(VfsPluginManager::instance().createVfsFromPlugin(newMode).release()); + // Restart VFS. _definition.virtualFilesMode = newMode; startVfs(); saveToSettings(); diff --git a/test/testsyncvirtualfiles.cpp b/test/testsyncvirtualfiles.cpp index f3f28077af2..c1c22e502dc 100644 --- a/test/testsyncvirtualfiles.cpp +++ b/test/testsyncvirtualfiles.cpp @@ -862,6 +862,8 @@ private slots: void testWipeVirtualSuffixFiles() { + // This tests the procedure done in Folder::setVirtualFilesEnabled. For changes here, make sure they are reflected in that method. + FakeFolder fakeFolder{ FileInfo{} }; setupVfs(fakeFolder);