From fe8e456aace3ccbb3503f9c8c4eb58f7fc75d69a Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Thu, 2 Dec 2021 13:56:23 +0100 Subject: [PATCH] Rename stop and unregisterFolder methods In case of `stop` this makes it clear if it is a temporary state and the connection is resumed later (e.g. when the client exits), or if it is permanent (e.g. when the sync older is going to be removed). --- src/common/vfs.h | 12 ++++++------ src/gui/folder.cpp | 11 +++++------ src/libsync/vfs/suffix/vfs_suffix.cpp | 4 ++-- src/libsync/vfs/suffix/vfs_suffix.h | 4 ++-- test/testutils/syncenginetestutils.cpp | 5 ++--- 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/common/vfs.h b/src/common/vfs.h index 7efde8ad768..02dce8060e7 100644 --- a/src/common/vfs.h +++ b/src/common/vfs.h @@ -142,11 +142,11 @@ class OCSYNC_EXPORT Vfs : public QObject */ void start(const VfsSetupParams ¶ms); - /// Stop interaction with VFS provider. Like when the client application quits. - virtual void stop() = 0; + /// Stop interaction with VFS provider, because the client is going to quit. + virtual void stopForExit() = 0; - /// Deregister the folder with the sync provider, like when a folder is removed. - virtual void unregisterFolder() = 0; + /// Stop and deregister the folder with the sync provider, like when a folder is removed. + virtual void stopAndUnregisterFolder() = 0; /** Whether the socket api should show pin state options @@ -285,8 +285,8 @@ class OCSYNC_EXPORT VfsOff : public Vfs QString fileSuffix() const override { return QString(); } - void stop() override {} - void unregisterFolder() override {} + void stopForExit() override {} + void stopAndUnregisterFolder() override {} bool socketApiPinStateActionsShown() const override { return false; } bool isHydrating() const override { return false; } diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp index 3617ccaef50..2015beb1889 100644 --- a/src/gui/folder.cpp +++ b/src/gui/folder.cpp @@ -175,8 +175,9 @@ Folder::Folder(const FolderDefinition &definition, Folder::~Folder() { // If wipeForRemoval() was called the vfs has already shut down. - if (_vfs) - _vfs->stop(); + if (_vfs) { + _vfs->stopForExit(); + } // Reset then engine first as it will abort and try to access members of the Folder _engine.reset(); @@ -709,8 +710,7 @@ void Folder::setVirtualFilesEnabled(bool enabled) // TODO: Must wait for current sync to finish! SyncEngine::wipeVirtualFiles(path(), _journal, *_vfs); - _vfs->stop(); - _vfs->unregisterFolder(); + _vfs->stopAndUnregisterFolder(); disconnect(_vfs.data(), nullptr, this, nullptr); disconnect(&_engine->syncFileStatusTracker(), nullptr, _vfs.data(), nullptr); @@ -852,8 +852,7 @@ void Folder::wipeForRemoval() QFile::remove(stateDbFile + "-wal"); QFile::remove(stateDbFile + "-journal"); - _vfs->stop(); - _vfs->unregisterFolder(); + _vfs->stopAndUnregisterFolder(); _vfs.reset(nullptr); // warning: folder now in an invalid state } diff --git a/src/libsync/vfs/suffix/vfs_suffix.cpp b/src/libsync/vfs/suffix/vfs_suffix.cpp index 1641c83831b..2040dd796f0 100644 --- a/src/libsync/vfs/suffix/vfs_suffix.cpp +++ b/src/libsync/vfs/suffix/vfs_suffix.cpp @@ -57,11 +57,11 @@ void VfsSuffix::startImpl(const VfsSetupParams ¶ms) Q_EMIT started(); } -void VfsSuffix::stop() +void VfsSuffix::stopForExit() { } -void VfsSuffix::unregisterFolder() +void VfsSuffix::stopAndUnregisterFolder() { } diff --git a/src/libsync/vfs/suffix/vfs_suffix.h b/src/libsync/vfs/suffix/vfs_suffix.h index f73a964b5d1..b44da6c2fc1 100644 --- a/src/libsync/vfs/suffix/vfs_suffix.h +++ b/src/libsync/vfs/suffix/vfs_suffix.h @@ -34,8 +34,8 @@ class VfsSuffix : public Vfs QString underlyingFileName(const QString &fileName) const override; - void stop() override; - void unregisterFolder() override; + void stopForExit() override; + void stopAndUnregisterFolder() override; bool socketApiPinStateActionsShown() const override { return true; } bool isHydrating() const override; diff --git a/test/testutils/syncenginetestutils.cpp b/test/testutils/syncenginetestutils.cpp index cc7604e6a1d..e67bfc4fa96 100644 --- a/test/testutils/syncenginetestutils.cpp +++ b/test/testutils/syncenginetestutils.cpp @@ -925,7 +925,7 @@ void FakeFolder::switchToVfs(QSharedPointer vfs) { auto opts = _syncEngine->syncOptions(); - opts._vfs->stop(); + opts._vfs->stopForExit(); QObject::disconnect(_syncEngine.get(), nullptr, opts._vfs.data(), nullptr); opts._vfs = vfs; @@ -940,8 +940,7 @@ void FakeFolder::switchToVfs(QSharedPointer vfs) vfsParams.providerDisplayName = QStringLiteral("OC-TEST"); vfsParams.providerVersion = QVersionNumber(0, 1); QObject::connect(_syncEngine.get(), &QObject::destroyed, vfs.data(), [vfs]() { - vfs->stop(); - vfs->unregisterFolder(); + vfs->stopAndUnregisterFolder(); }); QObject::connect(vfs.get(), &OCC::Vfs::error, vfs.get(), [](const QString &error) {