Skip to content

Commit 3ab87fc

Browse files
committed
Pause sync before we terminate
That ensures that a folder is not rescheduled Fixes: #632
1 parent 40e5978 commit 3ab87fc

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/gui/accountsettings.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,12 @@ void AccountSettings::slotEnableCurrentFolder(Folder *folder, bool terminate)
229229
{
230230
Q_ASSERT(folder);
231231
qCInfo(lcAccountSettings) << u"Application: enable folder with alias " << folder->path();
232-
bool currentlyPaused = false;
233232

234233
// this sets the folder status to disabled but does not interrupt it.
235-
currentlyPaused = folder->isSyncPaused();
234+
const bool currentlyPaused = folder->isSyncPaused();
236235
if (!currentlyPaused && !terminate) {
237236
// check if a sync is still running and if so, ask if we should terminate.
238-
if (FolderMan::instance()->scheduler()->currentSync() == folder) { // its still running
237+
if (FolderMan::instance()->scheduler()->currentSync() == folder) { // it's still running
239238
auto msgbox = new FontIconMessageBox(
240239
{u''}, tr("Sync Running"), tr("The sync operation is running.<br/>Do you want to stop it?"), QMessageBox::Yes | QMessageBox::No, this);
241240
msgbox->setAttribute(Qt::WA_DeleteOnClose);
@@ -250,14 +249,18 @@ void AccountSettings::slotEnableCurrentFolder(Folder *folder, bool terminate)
250249
}
251250
}
252251

253-
// message box can return at any time while the thread keeps running,
254-
// so better check again after the user has responded.
255-
if (FolderMan::instance()->scheduler()->currentSync() == folder && terminate) {
256-
FolderMan::instance()->scheduler()->terminateCurrentSync(tr("Sync paused by user"));
252+
if (currentlyPaused) {
253+
// ensure we don't forget about local errors
254+
folder->slotNextSyncFullLocalDiscovery();
255+
folder->setSyncPaused(false);
256+
} else {
257+
// set paused to prevent reschedule
258+
folder->setSyncPaused(true);
259+
// terminate the run if we previously where syncing
260+
if (FolderMan::instance()->scheduler()->currentSync() == folder && terminate) {
261+
FolderMan::instance()->scheduler()->terminateCurrentSync(tr("Sync paused by user"));
262+
}
257263
}
258-
folder->slotNextSyncFullLocalDiscovery(); // ensure we don't forget about local errors
259-
folder->setSyncPaused(!currentlyPaused);
260-
261264
_model->slotUpdateFolderState(folder);
262265
}
263266

0 commit comments

Comments
 (0)