From e7c2e4c9072b72162421965980419288f132656f Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 29 Mar 2018 18:18:19 +0200 Subject: Avoid deleting all contacts on resync by avoiding unnecessary work and reliance on quirks. --- examples/webdavcommon/webdav.cpp | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'examples/webdavcommon') diff --git a/examples/webdavcommon/webdav.cpp b/examples/webdavcommon/webdav.cpp index e86ebd1..05b5348 100644 --- a/examples/webdavcommon/webdav.cpp +++ b/examples/webdavcommon/webdav.cpp @@ -122,10 +122,6 @@ KAsync::Job WebDavSynchronizer::synchronizeWithSource(const Sink::QueryBas // for collections to be removed. auto collectionResourceIDs = QSharedPointer>::create(); - // Same but for items. - // Quirk: may contain a collection Id (see below) - auto itemsResourceIDs = QSharedPointer>::create(); - return job .serialEach([=](const KDAV2::DavCollection &collection) { auto collectionResourceID = resourceID(collection); @@ -135,26 +131,22 @@ KAsync::Job WebDavSynchronizer::synchronizeWithSource(const Sink::QueryBas if (unchanged(collection)) { SinkTrace() << "Collection unchanged:" << collectionResourceID; - // It seems that doing this prevent the items in the - // collection to be removed when doing scanForRemovals - // below (since the collection is unchanged, we do not go - // through all of its items). - // Behaviour copied from the previous code. - itemsResourceIDs->insert(collectionResourceID); - return KAsync::null(); } SinkTrace() << "Syncing collection:" << collectionResourceID; - return synchronizeCollection(collection, progress, total, itemsResourceIDs); + auto itemsResourceIDs = QSharedPointer>::create(); + return synchronizeCollection(collection, progress, total, itemsResourceIDs) + .then([=] { + scanForRemovals(itemName, [&itemsResourceIDs](const QByteArray &remoteId) { + return itemsResourceIDs->contains(remoteId); + }); + }); }) .then([=]() { scanForRemovals(collectionName, [&collectionResourceIDs](const QByteArray &remoteId) { return collectionResourceIDs->contains(remoteId); }); - scanForRemovals(itemName, [&itemsResourceIDs](const QByteArray &remoteId) { - return itemsResourceIDs->contains(remoteId); - }); }); } else { SinkWarning() << "Unknown query type"; -- cgit v1.2.3