Navigation Menu

Skip to content

Commit

Permalink
[buteo-sync-plugins-social] Discard spurious local addition due to do…
Browse files Browse the repository at this point in the history
…wnsync. 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.
  • Loading branch information
Chris Adams committed Jan 29, 2020
1 parent 9426b48 commit 747fe3f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/google/google-calendars/googlecalendarsyncadaptor.cpp
Expand Up @@ -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.
}
Expand All @@ -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");
Expand Down Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions src/google/google-calendars/googlecalendarsyncadaptor.h
Expand Up @@ -127,6 +127,7 @@ private Q_SLOTS:
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
Expand Down

0 comments on commit 747fe3f

Please sign in to comment.