Skip to content

Commit

Permalink
[buteo-sync-plugins-social] Improve clean sync of Google Calendars. C…
Browse files Browse the repository at this point in the history
…ontributes to MER#1162

This commit ensures that we don't delete the gcal.ini file on package
upgrade, which we previously did (which would then trigger a clean
sync cycle on next synchronization).

It also ensures that when a clean sync does occur (eg, due to error)
that we re-use the same notebook UID after recreating the notebook,
to ensure uid continuity for other applications (eg Calendar App).

Contributes to MER#1162
  • Loading branch information
Chris Adams committed Jul 14, 2015
1 parent bcbaf3d commit 44d9029
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 0 additions & 1 deletion rpm/sociald.spec
Expand Up @@ -194,7 +194,6 @@ Provides calendar synchronisation with Google
%pre google-calendars
rm -f /home/nemo/.cache/msyncd/sync/client/google-calendars.xml
rm -f /home/nemo/.cache/msyncd/sync/google.Calendars.xml
rm -f /home/nemo/.local/share/system/privileged/Sync/gcal.ini

%post google-calendars
systemctl-user try-restart msyncd.service || :
Expand Down
5 changes: 5 additions & 0 deletions src/google/google-calendars/googlecalendarsyncadaptor.cpp
Expand Up @@ -1310,10 +1310,12 @@ void GoogleCalendarSyncAdaptor::finishedRequestingRemoteEvents(int accountId, co
case GoogleCalendarSyncAdaptor::CleanSync: {
SOCIALD_LOG_DEBUG("Deleting and recreating local notebook for clean-sync server calendar:" << serverCalendarId);
// delete
QString notebookUid; // we wish to re-use the old notebook's UID after clean sync.
mKCal::Notebook::Ptr notebook = notebookForCalendarId(accountId, serverCalendarId);
if (!notebook.isNull()) {
SOCIALD_LOG_DEBUG("deleting notebook:" << notebook->uid() << "due to clean sync");
notebook->setIsReadOnly(false);
notebookUid = notebook->uid();
m_storage->deleteNotebook(notebook);
} else {
SOCIALD_LOG_DEBUG("could not find local notebook corresponding to server calendar:" << serverCalendarId);
Expand All @@ -1322,6 +1324,9 @@ void GoogleCalendarSyncAdaptor::finishedRequestingRemoteEvents(int accountId, co
SOCIALD_LOG_DEBUG("recreating notebook:" << notebook->uid() << "due to clean sync");
notebook = mKCal::Notebook::Ptr(new mKCal::Notebook);
notebook->setIsReadOnly(false);
if (!notebookUid.isEmpty()) {
notebook->setUid(notebookUid);
}
notebook->setName(m_serverCalendarIdToCalendarInfo[accountId].value(serverCalendarId).summary);
notebook->setColor(m_serverCalendarIdToCalendarInfo[accountId].value(serverCalendarId).color);
notebook->setDescription(m_serverCalendarIdToCalendarInfo[accountId].value(serverCalendarId).description);
Expand Down

0 comments on commit 44d9029

Please sign in to comment.