mirror of
https://github.com/chylex/Nextcloud-Desktop.git
synced 2025-05-16 17:34:09 +02:00
Vfs: Call unregisterFolder() when folder is removed
This commit is contained in:
parent
597cc60f52
commit
41f1ddb5fc
@ -140,8 +140,9 @@ 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
|
// If wipeForRemoval() was called the vfs has already shut down.
|
||||||
_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();
|
||||||
@ -745,20 +746,18 @@ void Folder::slotTerminateSync()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This removes the csync File database
|
void Folder::wipeForRemoval()
|
||||||
// This is needed to provide a clean startup again in case another
|
|
||||||
// local folder is synced to the same ownCloud.
|
|
||||||
void Folder::wipe()
|
|
||||||
{
|
{
|
||||||
QString stateDbFile = _engine->journal()->databaseFilePath();
|
|
||||||
|
|
||||||
// Delete files that have been partially downloaded.
|
// Delete files that have been partially downloaded.
|
||||||
slotDiscardDownloadProgress();
|
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());
|
FolderMan::instance()->socketApi()->slotUnregisterPath(alias());
|
||||||
_journal.close(); // close the sync journal
|
_journal.close(); // close the sync journal
|
||||||
|
|
||||||
|
// Remove db and temporaries
|
||||||
|
QString stateDbFile = _engine->journal()->databaseFilePath();
|
||||||
|
|
||||||
QFile file(stateDbFile);
|
QFile file(stateDbFile);
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
if (!file.remove()) {
|
if (!file.remove()) {
|
||||||
@ -776,8 +775,9 @@ void Folder::wipe()
|
|||||||
QFile::remove(stateDbFile + "-wal");
|
QFile::remove(stateDbFile + "-wal");
|
||||||
QFile::remove(stateDbFile + "-journal");
|
QFile::remove(stateDbFile + "-journal");
|
||||||
|
|
||||||
if (canSync())
|
_vfs->stop();
|
||||||
FolderMan::instance()->socketApi()->slotRegisterPath(alias());
|
_vfs->unregisterFolder();
|
||||||
|
_vfs.reset(nullptr); // warning: folder now in an invalid state
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Folder::reloadExcludes()
|
bool Folder::reloadExcludes()
|
||||||
|
@ -188,8 +188,12 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This is called when the sync folder definition is removed. Do cleanups here.
|
* 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);
|
void setSyncState(SyncResult::Status state);
|
||||||
|
|
||||||
|
@ -1127,8 +1127,8 @@ void FolderMan::removeFolder(Folder *f)
|
|||||||
emit scheduleQueueChanged();
|
emit scheduleQueueChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
f->wipe();
|
|
||||||
f->setSyncPaused(true);
|
f->setSyncPaused(true);
|
||||||
|
f->wipeForRemoval();
|
||||||
|
|
||||||
// remove the folder configuration
|
// remove the folder configuration
|
||||||
f->removeFromSettings();
|
f->removeFromSettings();
|
||||||
@ -1253,7 +1253,7 @@ void FolderMan::slotWipeFolderForAccount(AccountState *accountState)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// wipe database
|
// wipe database
|
||||||
f->wipe();
|
f->wipeForRemoval();
|
||||||
|
|
||||||
// wipe data
|
// wipe data
|
||||||
QDir userFolder(f->path());
|
QDir userFolder(f->path());
|
||||||
|
Loading…
Reference in New Issue
Block a user