Skip to content

Commit

Permalink
[buteo-sync-plugins-social] Avoid performing multiple clean-syncs. Co…
Browse files Browse the repository at this point in the history
…ntributes to JB#52608

When an account is initalised, a clean sync is initiated. However,
because the sync plugin version was left unset, the second was also
performed as a clean sync, even if the first was successful.

This change ensures the protocol version number gets stored correctly
after the first full sync in order to avoid this.
  • Loading branch information
llewelld committed Jan 29, 2021
1 parent 5ea2533 commit 013895e
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/google/google-calendars/googlecalendarsyncadaptor.cpp
Expand Up @@ -822,13 +822,11 @@ bool wasLastSyncSuccessful(int accountId, bool *needCleanSync)
*needCleanSync = settingsFile.value(QString::fromLatin1("%1-needCleanSync").arg(accountId), QVariant::fromValue<bool>(false)).toBool();
bool retn = settingsFile.value(QString::fromLatin1("%1-success").arg(accountId), QVariant::fromValue<bool>(false)).toBool();
settingsFile.setValue(QString::fromLatin1("%1-success").arg(accountId), QVariant::fromValue<bool>(false));
int pluginVersion = settingsFile.value(QString::fromLatin1("%1-pluginVersion").arg(accountId), QVariant::fromValue<int>(1)).toInt();
int pluginVersion = settingsFile.value(QString::fromLatin1("%1-pluginVersion").arg(accountId), QVariant::fromValue<int>(GOOGLE_CAL_SYNC_PLUGIN_VERSION)).toInt();
if (pluginVersion != GOOGLE_CAL_SYNC_PLUGIN_VERSION) {
settingsFile.setValue(QString::fromLatin1("%1-pluginVersion").arg(accountId), GOOGLE_CAL_SYNC_PLUGIN_VERSION);
SOCIALD_LOG_DEBUG("Google cal sync plugin version mismatch, force clean sync");
retn = false;
}
settingsFile.sync();
return retn;
}

Expand All @@ -840,7 +838,7 @@ void setLastSyncSuccessful(int accountId)
QSettings settingsFile(settingsFileName, QSettings::IniFormat);
settingsFile.setValue(QString::fromLatin1("%1-needCleanSync").arg(accountId), QVariant::fromValue<bool>(false));
settingsFile.setValue(QString::fromLatin1("%1-success").arg(accountId), QVariant::fromValue<bool>(true));
settingsFile.sync();
settingsFile.setValue(QString::fromLatin1("%1-pluginVersion").arg(accountId), GOOGLE_CAL_SYNC_PLUGIN_VERSION);
}

// Move all items with a recurrenceId after those without
Expand Down

0 comments on commit 013895e

Please sign in to comment.