Skip to content

Commit

Permalink
Merge branch 'jb33353' into 'master'
Browse files Browse the repository at this point in the history
Signal external syncs to stop during backup/restore

See merge request mer-core/buteo-syncfw!47
  • Loading branch information
llewelld committed May 4, 2020
2 parents 21fcd0e + 5bb3da4 commit 2dd2dde
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
14 changes: 7 additions & 7 deletions msyncd/SyncBackup.cpp
Expand Up @@ -83,13 +83,13 @@ SyncBackup::~SyncBackup()

void SyncBackup::backupServiceUnregistered(const QString &serviceName)
{
FUNCTION_CALL_TRACE;
Q_UNUSED (serviceName);
if (iBackupRestore) {
// Should not happen ; backup framework exitted abruptly
emit restoreDone();
}
iBackupRestore = false;
FUNCTION_CALL_TRACE;
Q_UNUSED (serviceName);
if (iBackupRestore) {
// Should not happen ; backup framework exited abruptly
iBackupRestore = false;
emit restoreDone();
}
}

uchar SyncBackup::sendDelayReply (const QDBusMessage &message)
Expand Down
2 changes: 1 addition & 1 deletion msyncd/SyncBackup.h
Expand Up @@ -62,7 +62,7 @@ class SyncBackup : public SyncBackupProxy // Derived from QObject
*/
void sendReply (uchar aResult);

signals :
signals:

public slots:
// From backup framework ...
Expand Down
26 changes: 22 additions & 4 deletions msyncd/synchronizer.cpp
Expand Up @@ -168,11 +168,13 @@ bool Synchronizer::initialize()

startServers();

// For Backup/restore handling
iSyncBackup = new SyncBackup();

// Initialize scheduler
initializeScheduler();

// For Backup/restore handling
iSyncBackup = new SyncBackup();
// Connect backup signals after the scheduler has been initialized
connect(iSyncBackup, SIGNAL(startBackup()),this, SLOT(backupStarts()));
connect(iSyncBackup, SIGNAL(backupDone()),this, SLOT(backupFinished()));
connect(iSyncBackup, SIGNAL(startRestore()),this, SLOT(restoreStarts()));
Expand Down Expand Up @@ -1750,6 +1752,14 @@ void Synchronizer::backupRestoreStarts ()
delete iSyncScheduler;
iSyncScheduler = 0;

// Request all external syncs to stop, relying on externalSyncStatus() to
// act appropriately because (getBackUpRestoreState() == true)
QMap<QString, bool>::iterator syncStatus;
for (syncStatus = iExternalSyncProfileStatus.begin();
syncStatus != iExternalSyncProfileStatus.end(); ++syncStatus) {
const QString &profileName = syncStatus.key();
externalSyncStatus(profileName, false);
}
}

void Synchronizer::backupRestoreFinished()
Expand Down Expand Up @@ -2131,8 +2141,16 @@ void Synchronizer::externalSyncStatus(const SyncProfile* aProfile, bool aQuery)
if (accountId) {
const QString &profileName = aProfile->name();
const QString &clientProfile = aProfile->clientProfile()->name();

// All external syncs are stopped while a backup or restore is running
if (getBackUpRestoreState()) {
if (iExternalSyncProfileStatus.value(profileName) || aQuery) {
LOG_DEBUG("Sync externally status suspended during backup for profile:" << profileName);
iExternalSyncProfileStatus.insert(profileName, false);
emit syncedExternallyStatus(accountId, clientProfile, false);
}
// Account in set to sync externally, buteo will let external process handle the syncs in this case
if (aProfile->syncExternallyEnabled()) {
} else if (aProfile->syncExternallyEnabled()) {
if (!iExternalSyncProfileStatus.value(profileName)) {
LOG_DEBUG("Sync externally status changed from false to true for profile:" << profileName);
iExternalSyncProfileStatus.insert(profileName, true);
Expand Down Expand Up @@ -2182,7 +2200,7 @@ void Synchronizer::removeExternalSyncStatus(const SyncProfile *aProfile)
if (iExternalSyncProfileStatus.contains(profileName)) {
// if profile was set to sync externally emit the change state signal
if (iExternalSyncProfileStatus.value(profileName)) {
emit syncedExternallyStatus(accountId, aProfile->clientProfile()->name(),false);
emit syncedExternallyStatus(accountId, aProfile->clientProfile()->name(), false);
}
iExternalSyncProfileStatus.remove(profileName);
LOG_DEBUG("Removing sync externally status for profile:" << profileName);
Expand Down

0 comments on commit 2dd2dde

Please sign in to comment.