Vfs: Call unregisterFolder() when folder is removed

This commit is contained in:
Christian Kamm 2019-01-25 13:16:32 +01:00 коммит произвёл Kevin Ottens
Родитель 597cc60f52
Коммит 41f1ddb5fc
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 074BBBCB8DECC9E2
3 изменённых файлов: 18 добавлений и 14 удалений

Просмотреть файл

@ -140,8 +140,9 @@ 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 wipeForRemoval() was called the vfs has already shut down.
if (_vfs)
_vfs->stop();
// Reset then engine first as it will abort and try to access members of the Folder
_engine.reset();
@ -745,20 +746,18 @@ void Folder::slotTerminateSync()
}
}
// This removes the csync File database
// This is needed to provide a clean startup again in case another
// local folder is synced to the same ownCloud.
void Folder::wipe()
void Folder::wipeForRemoval()
{
QString stateDbFile = _engine->journal()->databaseFilePath();
// Delete files that have been partially downloaded.
slotDiscardDownloadProgress();
//Unregister the socket API so it does not keep the .sync_journal file open
// Unregister the socket API so it does not keep the .sync_journal file open
FolderMan::instance()->socketApi()->slotUnregisterPath(alias());
_journal.close(); // close the sync journal
// Remove db and temporaries
QString stateDbFile = _engine->journal()->databaseFilePath();
QFile file(stateDbFile);
if (file.exists()) {
if (!file.remove()) {
@ -776,8 +775,9 @@ void Folder::wipe()
QFile::remove(stateDbFile + "-wal");
QFile::remove(stateDbFile + "-journal");
if (canSync())
FolderMan::instance()->socketApi()->slotRegisterPath(alias());
_vfs->stop();
_vfs->unregisterFolder();
_vfs.reset(nullptr); // warning: folder now in an invalid state
}
bool Folder::reloadExcludes()

Просмотреть файл

@ -188,8 +188,12 @@ public:
/**
* This is called when the sync folder definition is removed. Do cleanups here.
*
* It removes the database, among other things.
*
* The folder is not in a valid state afterwards!
*/
virtual void wipe();
virtual void wipeForRemoval();
void setSyncState(SyncResult::Status state);

Просмотреть файл

@ -1127,8 +1127,8 @@ void FolderMan::removeFolder(Folder *f)
emit scheduleQueueChanged();
}
f->wipe();
f->setSyncPaused(true);
f->wipeForRemoval();
// remove the folder configuration
f->removeFromSettings();
@ -1253,7 +1253,7 @@ void FolderMan::slotWipeFolderForAccount(AccountState *accountState)
}
// wipe database
f->wipe();
f->wipeForRemoval();
// wipe data
QDir userFolder(f->path());