vfs: Fix dealing with missing vfs instance

Maybe there should just be a VfsOff instance to make this less error
prone.
This commit is contained in:
Christian Kamm 2018-11-14 10:44:34 +01:00 committed by Kevin Ottens
parent bfe136da7a
commit 85dd10eb9b
No known key found for this signature in database
GPG key ID: 074BBBCB8DECC9E2

View file

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