diff options
author | Hannah von Reth <hannah.vonreth@owncloud.com> | 2021-09-13 16:01:34 +0300 |
---|---|---|
committer | Hannah von Reth <vonreth@kde.org> | 2021-09-15 18:20:01 +0300 |
commit | 65b67b3ff594b5b9baa6f52108510afff1c99f7c (patch) | |
tree | 8f1d6b1938c35ee219c599ffbdbafbf265d8c284 /src/gui/folder.cpp | |
parent | c0b4c4817cfd858d9a59bb67e4a65a532c1fdfe3 (diff) |
Fix crash on missing sync root
Fixes: #9016
Diffstat (limited to 'src/gui/folder.cpp')
-rw-r--r-- | src/gui/folder.cpp | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp index 98e885056..f4c0cbaa5 100644 --- a/src/gui/folder.cpp +++ b/src/gui/folder.cpp @@ -77,7 +77,7 @@ Folder::Folder(const FolderDefinition &definition, _syncResult.setStatus(status); // check if the local path exists - checkLocalPath(); + const auto folderOk = checkLocalPath(); _syncResult.setFolder(_definition.alias); @@ -141,8 +141,10 @@ Folder::Folder(const FolderDefinition &definition, saveToSettings(); } - // Initialize the vfs plugin - startVfs(); + if (folderOk) { + // Initialize the vfs plugin + startVfs(); + } } Folder::~Folder() @@ -155,7 +157,7 @@ Folder::~Folder() _engine.reset(); } -void Folder::checkLocalPath() +bool Folder::checkLocalPath() { const QFileInfo fi(_definition.localPath); _canonicalLocalPath = fi.canonicalFilePath(); @@ -173,18 +175,22 @@ void Folder::checkLocalPath() if (fi.isDir() && fi.isReadable()) { qCDebug(lcFolder) << "Checked local path ok"; } else { + QString error; // Check directory again if (!FileSystem::fileExists(_definition.localPath, fi)) { - _syncResult.appendErrorString(tr("Local folder %1 does not exist.").arg(_definition.localPath)); - _syncResult.setStatus(SyncResult::SetupError); + error = tr("Local folder %1 does not exist.").arg(_definition.localPath); } else if (!fi.isDir()) { - _syncResult.appendErrorString(tr("%1 should be a folder but is not.").arg(_definition.localPath)); - _syncResult.setStatus(SyncResult::SetupError); + error = tr("%1 should be a folder but is not.").arg(_definition.localPath); } else if (!fi.isReadable()) { - _syncResult.appendErrorString(tr("%1 is not readable.").arg(_definition.localPath)); + error = tr("%1 is not readable.").arg(_definition.localPath); + } + if (!error.isEmpty()) { + _syncResult.appendErrorString(error); _syncResult.setStatus(SyncResult::SetupError); + return false; } } + return true; } QString Folder::shortGuiRemotePathOrAppName() const @@ -283,7 +289,7 @@ bool Folder::syncPaused() const bool Folder::canSync() const { - return !syncPaused() && accountState()->isConnected(); + return !syncPaused() && accountState()->isConnected() && _syncResult.status() != SyncResult::SetupError; } bool Folder::dueToSync() const @@ -495,6 +501,13 @@ void Folder::startVfs() OC_ENFORCE(_vfs); OC_ENFORCE(_vfs->mode() == _definition.virtualFilesMode); + const auto result = Vfs::checkAvailability(path(), _vfs->mode()); + if (!result) { + _syncResult.appendErrorString(result.error()); + _syncResult.setStatus(SyncResult::SetupError); + return; + } + VfsSetupParams vfsParams; vfsParams.filesystemPath = path(); vfsParams.remotePath = remotePathTrailingSlash(); |