Skip to content

Commit

Permalink
Rename stop and unregisterFolder methods
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
erikjv committed Dec 2, 2021
1 parent d90d92b commit fe8e456
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 19 deletions.
12 changes: 6 additions & 6 deletions src/common/vfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ class OCSYNC_EXPORT Vfs : public QObject
*/
void start(const VfsSetupParams &params);

/// 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
Expand Down Expand Up @@ -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; }
Expand Down
11 changes: 5 additions & 6 deletions src/gui/folder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions src/libsync/vfs/suffix/vfs_suffix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ void VfsSuffix::startImpl(const VfsSetupParams &params)
Q_EMIT started();
}

void VfsSuffix::stop()
void VfsSuffix::stopForExit()
{
}

void VfsSuffix::unregisterFolder()
void VfsSuffix::stopAndUnregisterFolder()
{
}

Expand Down
4 changes: 2 additions & 2 deletions src/libsync/vfs/suffix/vfs_suffix.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions test/testutils/syncenginetestutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ void FakeFolder::switchToVfs(QSharedPointer<OCC::Vfs> vfs)
{
auto opts = _syncEngine->syncOptions();

opts._vfs->stop();
opts._vfs->stopForExit();
QObject::disconnect(_syncEngine.get(), nullptr, opts._vfs.data(), nullptr);

opts._vfs = vfs;
Expand All @@ -940,8 +940,7 @@ void FakeFolder::switchToVfs(QSharedPointer<OCC::Vfs> 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) {
Expand Down

0 comments on commit fe8e456

Please sign in to comment.