Commit 747fe3f4 authored by chriadam's avatar chriadam

[buteo-sync-plugins-social] Discard spurious local addition due to downsync....

[buteo-sync-plugins-social] Discard spurious local addition due to downsync. Contributes to JB#47783

Previously, we would determine that local additions caused by a
downsync during the previous sync cycle should be treated as
local modifications, and upsynced.

This commit checks whether a local modification has indeed occurred
by checking the lastModified date stamp, and if no modification has
occurred, discarding the change to prevent spurious upsync.

It also fixes a bug where the wrong "since" date time would be used
when determining the local changeset, as it may be using one from
a different notebook by mistake.  This commit updates the code so
that the appropriate previous sync date for the specific notebook
is used.
parent 9426b482
......@@ -1553,6 +1553,7 @@ void GoogleCalendarSyncAdaptor::finishedRequestingRemoteEvents(int accountId, co
m_calendarsFinishedRequested.insert(calendarId, updateTimestampStr);
m_calendarsThisSyncTokens.insert(calendarId, syncToken);
m_calendarsNextSyncTokens.insert(calendarId, nextSyncToken);
m_calendarsSyncDate.insert(calendarId, since);
if (!m_calendarsBeingRequested.isEmpty()) {
return; // still waiting for more requests to finish.
}
......@@ -1573,7 +1574,7 @@ void GoogleCalendarSyncAdaptor::finishedRequestingRemoteEvents(int accountId, co
}
// now upsync the local changes to the remote server
QList<UpsyncChange> changesToUpsync = determineSyncDelta(accountId, accessToken, finishedCalendarId, since);
QList<UpsyncChange> changesToUpsync = determineSyncDelta(accountId, accessToken, finishedCalendarId, m_calendarsSyncDate.value(finishedCalendarId));
if (changesToUpsync.size()) {
if (syncAborted()) {
SOCIALD_LOG_DEBUG("skipping upsync of queued upsync changes due to sync being aborted");
......@@ -1960,8 +1961,13 @@ QList<GoogleCalendarSyncAdaptor::UpsyncChange> GoogleCalendarSyncAdaptor::determ
SOCIALD_LOG_DEBUG("Converting local addition to modification due to clean-sync semantics");
} else {
// this event was previously downsynced from the remote in the last sync cycle.
// we treat it as a local modification (as it may have changed locally since).
// TODO: detect whether any actual change has occurred since it was downsynced. How?
// check to see whether it has changed locally since we downsynced it.
if (event->lastModified().dateTime() < since) {
SOCIALD_LOG_DEBUG("Discarding local event addition:" << event->uid() << event->recurrenceId().toString() << "as spurious due to downsync, for gcalId:" << gcalId);
discardedLocalModifications++;
continue;
}
// we treat it as a local modification (as it has changed locally since it was downsynced).
SOCIALD_LOG_DEBUG("Converting local addition to modification due to it being a previously downsynced event");
}
// convert the local event to a JSON object.
......
......@@ -127,6 +127,7 @@ private:
QMap<QString, QString> m_calendarsFinishedRequested; // calendarId to updated timestamp string
QMap<QString, QString> m_calendarsThisSyncTokens; // calendarId to sync token used during this sync cycle
QMap<QString, QString> m_calendarsNextSyncTokens; // calendarId to sync token to use during next sync cycle
QMap<QString, QDateTime> m_calendarsSyncDate; // calendarId to since date to use when determining delta
QMultiMap<QString, QPair<GoogleCalendarSyncAdaptor::ChangeType, QJsonObject> > m_changesFromDownsync; // calendarId to change
QMultiMap<QString, QPair<KCalCore::Event::Ptr, QJsonObject> > m_changesFromUpsync; // calendarId to event+upsyncResponse
QSet<QString> m_syncTokenFailure; // calendarIds suffering from 410 error due to invalid sync token
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment