From da945336477fbe8a9302f323804d578cb62c510c Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Thu, 4 Sep 2014 10:12:54 +0200 Subject: [PATCH] Folders: Signout should not switch folders to paused state. #2112 On signout, syncs that are running in folders are aborted. That used to also switch the state of these folders to 'paused'. To fix that, aborts that are caused by user actions no longer change the folder paused state. Aborts due to errors should still pause folders! Otherwise we'd try resyncing them even though there was an error. --- src/mirall/accountsettings.cpp | 4 ++-- src/mirall/folder.cpp | 8 ++++++-- src/mirall/folder.h | 1 + src/mirall/folderman.cpp | 8 -------- src/mirall/folderman.h | 6 +++++- src/mirall/selectivesyncdialog.cpp | 2 +- 6 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/mirall/accountsettings.cpp b/src/mirall/accountsettings.cpp index fc0c56ae9..c25d891e3 100644 --- a/src/mirall/accountsettings.cpp +++ b/src/mirall/accountsettings.cpp @@ -383,7 +383,7 @@ void AccountSettings::slotResetCurrentFolder() if( ret == QMessageBox::Yes ) { FolderMan *folderMan = FolderMan::instance(); Folder *f = folderMan->folder(alias); - f->slotTerminateSync(); + f->slotTerminateAndPauseSync(); f->wipe(); folderMan->slotScheduleAllFolders(); } @@ -499,7 +499,7 @@ void AccountSettings::slotEnableCurrentFolder() // message box can return at any time while the thread keeps running, // so better check again after the user has responded. if ( f->isBusy() && terminate ) { - f->slotTerminateSync(); + f->slotTerminateAndPauseSync(); } f->setSyncPaused(!currentlyPaused); // toggle the pause setting folderMan->slotSetFolderPaused( alias, !currentlyPaused ); diff --git a/src/mirall/folder.cpp b/src/mirall/folder.cpp index 914a342c0..c59e2fa72 100644 --- a/src/mirall/folder.cpp +++ b/src/mirall/folder.cpp @@ -496,12 +496,16 @@ void Folder::slotTerminateSync() // Do not display an error message, user knows his own actions. // _errors.append( tr("The CSync thread terminated.") ); // _csyncError = true; - FolderMan::instance()->slotSetFolderPaused(alias(), true); setSyncState(SyncResult::SyncAbortRequested); - return; } } +void Folder::slotTerminateAndPauseSync() +{ + slotTerminateSync(); + FolderMan::instance()->slotSetFolderPaused(alias(), true); +} + // 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. diff --git a/src/mirall/folder.h b/src/mirall/folder.h index b5eff8e59..0c255804e 100644 --- a/src/mirall/folder.h +++ b/src/mirall/folder.h @@ -138,6 +138,7 @@ public slots: * terminate the current sync run */ void slotTerminateSync(); + void slotTerminateAndPauseSync(); void slotAboutToRemoveAllFiles(SyncFileItem::Direction, bool*); diff --git a/src/mirall/folderman.cpp b/src/mirall/folderman.cpp index 2cea12209..61d768c2f 100644 --- a/src/mirall/folderman.cpp +++ b/src/mirall/folderman.cpp @@ -226,14 +226,6 @@ bool FolderMan::ensureJournalGone(const QString &localPath) return true; } -void FolderMan::terminateCurrentSync() -{ - if( !_currentSyncFolder.isEmpty() ) { - qDebug() << "Terminating syncing on folder " << _currentSyncFolder; - terminateSyncProcess( _currentSyncFolder ); - } -} - #define SLASH_TAG QLatin1String("__SLASH__") #define BSLASH_TAG QLatin1String("__BSLASH__") #define QMARK_TAG QLatin1String("__QMARK__") diff --git a/src/mirall/folderman.h b/src/mirall/folderman.h index e51b93afc..27723e03e 100644 --- a/src/mirall/folderman.h +++ b/src/mirall/folderman.h @@ -107,6 +107,11 @@ public slots: void slotFolderSyncStarted(); void slotFolderSyncFinished( const SyncResult& ); + /** + * Terminates the specified folder sync (or the current one). + * + * It does not switch the folder to paused state. + */ void terminateSyncProcess( const QString& alias = QString::null ); /* unload and delete on folder object */ @@ -134,7 +139,6 @@ private slots: private: // finds all folder configuration files // and create the folders - void terminateCurrentSync(); QString getBackupName( const QString& ) const; void registerFolderMonitor( Folder *folder ); diff --git a/src/mirall/selectivesyncdialog.cpp b/src/mirall/selectivesyncdialog.cpp index c73074341..081cfdb0d 100644 --- a/src/mirall/selectivesyncdialog.cpp +++ b/src/mirall/selectivesyncdialog.cpp @@ -291,7 +291,7 @@ void SelectiveSyncDialog::accept() FolderMan *folderMan = FolderMan::instance(); if (_folder->isBusy()) { - _folder->slotTerminateSync(); + _folder->slotTerminateAndPauseSync(); } folderMan->slotScheduleSync(_folder->alias()); }