Branch 'kolab/integration/4.13.0' - akonadi/collectionsync.cpp
Christian Mollekopf
mollekopf at kolabsys.com
Wed Dec 24 14:01:26 CET 2014
akonadi/collectionsync.cpp | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
New commits:
commit b143ed354587e4e287c62b6f1ca0c47d7cbcabe3
Author: Christian Mollekopf <chrigi_1 at fastmail.fm>
Date: Tue Dec 23 12:18:23 2014 +0100
CollectionSync: Fixed keep local changes
The code accidentally ignored CONTENTMIMETYPES isntead of attr->type().
A small refactoring should avoid those errors in the future,
and make the code more readable.
diff --git a/akonadi/collectionsync.cpp b/akonadi/collectionsync.cpp
index d8621c3..e3bf40b 100644
--- a/akonadi/collectionsync.cpp
+++ b/akonadi/collectionsync.cpp
@@ -360,12 +360,17 @@ public:
execute();
}
+ bool ignoreAttributeChanges(const Akonadi::Collection &col, const QByteArray &attribute) const
+ {
+ return (keepLocalChanges.contains(attribute) || col.keepLocalChanges().contains(attribute));
+ }
+
/**
Checks if the given localCollection and remoteCollection are different
*/
bool collectionNeedsUpdate(const Collection &localCollection, const Collection &remoteCollection) const
{
- if (!keepLocalChanges.contains(CONTENTMIMETYPES) && !remoteCollection.keepLocalChanges().contains(CONTENTMIMETYPES)) {
+ if (!ignoreAttributeChanges(remoteCollection, CONTENTMIMETYPES)) {
if (localCollection.contentMimeTypes().size() != remoteCollection.contentMimeTypes().size()) {
return true;
} else {
@@ -400,7 +405,7 @@ public:
// CollectionModifyJob adds the remote attributes to the local collection
Q_FOREACH (const Attribute *attr, remoteCollection.attributes()) {
const Attribute *localAttr = localCollection.attribute(attr->type());
- if (localAttr && (keepLocalChanges.contains(attr->type()) || remoteCollection.keepLocalChanges().contains(CONTENTMIMETYPES))) {
+ if (localAttr && ignoreAttributeChanges(remoteCollection, attr->type())) {
continue;
}
// The attribute must both exist and have equal contents
@@ -542,11 +547,11 @@ public:
Q_ASSERT(!upd.remoteId().isEmpty());
Q_ASSERT(currentTransaction);
upd.setId(local.id());
- if (keepLocalChanges.contains(CONTENTMIMETYPES) || remote.keepLocalChanges().contains(CONTENTMIMETYPES)) {
+ if (ignoreAttributeChanges(remote, CONTENTMIMETYPES)) {
upd.setContentMimeTypes(local.contentMimeTypes());
}
Q_FOREACH (Attribute *remoteAttr, upd.attributes()) {
- if ((keepLocalChanges.contains(remoteAttr->type()) || remote.keepLocalChanges().contains(remoteAttr->type()))&& local.hasAttribute(remoteAttr->type())) {
+ if (ignoreAttributeChanges(remote, remoteAttr->type()) && local.hasAttribute(remoteAttr->type())) {
//We don't want to overwrite the attribute changes with the defaults provided by the resource.
Attribute *localAttr = local.attribute(remoteAttr->type());
upd.removeAttribute(localAttr->type());
More information about the commits
mailing list