vfs: Fix dealing with missing vfs instance
authorChristian Kamm <mail@ckamm.de>
Wed, 14 Nov 2018 09:44:34 +0000 (10:44 +0100)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 15 Dec 2020 09:58:24 +0000 (10:58 +0100)
Maybe there should just be a VfsOff instance to make this less error
prone.

src/gui/folder.cpp

index bb1c1c880d969a7ebde7f35d7c10e1554906f6c7..270223810782164178c87adb194bdc2089d261f5 100644 (file)
@@ -140,7 +140,8 @@ Folder::Folder(const FolderDefinition &definition,
 Folder::~Folder()
 {
     // TODO cfapi: unregister on wipe()? There should probably be a wipeForRemoval() where this cleanup is appropriate
-    _vfs->stop();
+    if (_vfs)
+        _vfs->stop();
 
     // Reset then engine first as it will abort and try to access members of the Folder
     _engine.reset();
@@ -246,7 +247,7 @@ bool Folder::isBusy() const
 
 bool Folder::isSyncRunning() const
 {
-    return _engine->isSyncRunning() || _vfs->isHydrating();
+    return _engine->isSyncRunning() || (_vfs && _vfs->isHydrating());
 }
 
 QString Folder::remotePath() const
@@ -605,6 +606,8 @@ void Folder::setUseVirtualFiles(bool enabled)
         _saveInFoldersWithPlaceholders = true;
     }
     if (!enabled && _definition.virtualFilesMode != Vfs::Off) {
+        ENFORCE(_vfs);
+
         // TODO: Must wait for current sync to finish!
         SyncEngine::wipeVirtualFiles(path(), _journal, _vfs);