Skip to content

Commit

Permalink
Document Folder::setVirtualFilesEnabled(bool)
Browse files Browse the repository at this point in the history
The procedure is tested in `Vfs::wipeDehydratedVirtualFiles()`.
  • Loading branch information
erikjv authored and fmoc committed Nov 6, 2023
1 parent ccf44d1 commit 1bd57fc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/gui/folder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions test/testsyncvirtualfiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 1bd57fc

Please sign in to comment.