From 918400b4b04c9f065572953f3500cba3d2382b9e Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Sun, 3 Feb 2008 11:23:30 +0000 Subject: [PATCH] always rebuild local tracking status during slow and refresh syncs git-svn-id: https://zeitsenke.de/svn/SyncEvolution/trunk@499 15ad00c4-1369-45f4-8270-35d70d36bdcd --- src/TrackingSyncSource.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/TrackingSyncSource.cpp b/src/TrackingSyncSource.cpp index 2f771f50..c3763c13 100644 --- a/src/TrackingSyncSource.cpp +++ b/src/TrackingSyncSource.cpp @@ -33,6 +33,19 @@ void TrackingSyncSource::beginSyncThrow(bool needAll, RevisionMap_t revisions; listAllItems(revisions); + // slow sync or refresh-from-server/client: clear tracking node and + // recreate it based on current content of database + if (!needPartial) { + ArrayList uids; + ArrayList modTimes; + m_trackingNode->readProperties(&uids, &modTimes); + for (int i = 0; i < uids.size(); i++ ) { + const StringBuffer *uid = (StringBuffer *)uids[i]; + m_deletedItems.addItem(uid->c_str()); + m_trackingNode->removeProperty(uid->c_str()); + } + } + for (RevisionMap_t::const_iterator it = revisions.begin(); it != revisions.end(); it++) { @@ -41,7 +54,6 @@ void TrackingSyncSource::beginSyncThrow(bool needAll, if (deleteLocal) { deleteItem(uid); - m_trackingNode->removeProperty(uid.c_str()); } else { // always remember the item, need full list to find deleted items m_allItems.addItem(uid); @@ -58,10 +70,16 @@ void TrackingSyncSource::beginSyncThrow(bool needAll, m_trackingNode->setPropertyValue(uid.c_str(), revision.c_str()); } } + } else { + // refresh-from-client: make sure that all items we are about + // to send to server are also in our tracking node (otherwise + // the next incremental sync will go wrong) + m_trackingNode->setPropertyValue(uid.c_str(), revision.c_str()); } } } + // clear information about all items that we recognized as deleted if (needPartial) { ArrayList uids; ArrayList modTimes;