diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-06-03 15:50:06 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-06-03 15:50:06 +0200 |
commit | 5c08ecda71cdbfd8951f9aab657cd2e2697ad0b3 (patch) | |
tree | 3178694224cd12b99111eddb1ba1b61d90ec8d60 /common/sourcewriteback.cpp | |
parent | 77562cdae63e0ec7b09e8ece6af97165ba9e48dd (diff) | |
download | sink-5c08ecda71cdbfd8951f9aab657cd2e2697ad0b3.tar.gz sink-5c08ecda71cdbfd8951f9aab657cd2e2697ad0b3.zip |
Track modified properties to detect necessary replay changes
Diffstat (limited to 'common/sourcewriteback.cpp')
-rw-r--r-- | common/sourcewriteback.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/common/sourcewriteback.cpp b/common/sourcewriteback.cpp index 87f6934..a277606 100644 --- a/common/sourcewriteback.cpp +++ b/common/sourcewriteback.cpp | |||
@@ -21,6 +21,7 @@ | |||
21 | 21 | ||
22 | #include "definitions.h" | 22 | #include "definitions.h" |
23 | #include "log.h" | 23 | #include "log.h" |
24 | #include "bufferutils.h" | ||
24 | 25 | ||
25 | #define ENTITY_TYPE_MAIL "mail" | 26 | #define ENTITY_TYPE_MAIL "mail" |
26 | #define ENTITY_TYPE_FOLDER "folder" | 27 | #define ENTITY_TYPE_FOLDER "folder" |
@@ -74,20 +75,25 @@ KAsync::Job<void> SourceWriteBack::replay(const QByteArray &type, const QByteArr | |||
74 | // const qint64 revision = metadataBuffer ? metadataBuffer->revision() : -1; | 75 | // const qint64 revision = metadataBuffer ? metadataBuffer->revision() : -1; |
75 | const auto operation = metadataBuffer ? metadataBuffer->operation() : Sink::Operation_Creation; | 76 | const auto operation = metadataBuffer ? metadataBuffer->operation() : Sink::Operation_Creation; |
76 | const auto uid = Sink::Storage::uidFromKey(key); | 77 | const auto uid = Sink::Storage::uidFromKey(key); |
78 | const auto modifiedProperties = metadataBuffer->modifiedProperties() ? BufferUtils::fromVector(*metadataBuffer->modifiedProperties()) : QByteArrayList(); | ||
77 | QByteArray oldRemoteId; | 79 | QByteArray oldRemoteId; |
78 | 80 | ||
79 | if (operation != Sink::Operation_Creation) { | 81 | if (operation != Sink::Operation_Creation) { |
80 | oldRemoteId = syncStore().resolveLocalId(type, uid); | 82 | oldRemoteId = syncStore().resolveLocalId(type, uid); |
83 | if (oldRemoteId.isEmpty()) { | ||
84 | Warning() << "Couldn't find the remote id for: " << type << uid; | ||
85 | return KAsync::error<void>(1, "Couldn't find the remote id."); | ||
86 | } | ||
81 | } | 87 | } |
82 | Trace() << "Replaying " << key << type << oldRemoteId; | 88 | Trace() << "Replaying " << key << type << uid << oldRemoteId; |
83 | 89 | ||
84 | KAsync::Job<QByteArray> job = KAsync::null<QByteArray>(); | 90 | KAsync::Job<QByteArray> job = KAsync::null<QByteArray>(); |
85 | if (type == ENTITY_TYPE_FOLDER) { | 91 | if (type == ENTITY_TYPE_FOLDER) { |
86 | auto folder = store().readFromKey<ApplicationDomain::Folder>(key); | 92 | auto folder = store().readFromKey<ApplicationDomain::Folder>(key); |
87 | job = replay(folder, operation, oldRemoteId); | 93 | job = replay(folder, operation, oldRemoteId, modifiedProperties); |
88 | } else if (type == ENTITY_TYPE_MAIL) { | 94 | } else if (type == ENTITY_TYPE_MAIL) { |
89 | auto mail = store().readFromKey<ApplicationDomain::Mail>(key); | 95 | auto mail = store().readFromKey<ApplicationDomain::Mail>(key); |
90 | job = replay(mail, operation, oldRemoteId); | 96 | job = replay(mail, operation, oldRemoteId, modifiedProperties); |
91 | } | 97 | } |
92 | 98 | ||
93 | return job.then<void, QByteArray>([this, operation, type, uid, oldRemoteId](const QByteArray &remoteId) { | 99 | return job.then<void, QByteArray>([this, operation, type, uid, oldRemoteId](const QByteArray &remoteId) { |
@@ -125,12 +131,12 @@ KAsync::Job<void> SourceWriteBack::replay(const QByteArray &type, const QByteArr | |||
125 | }); | 131 | }); |
126 | } | 132 | } |
127 | 133 | ||
128 | KAsync::Job<QByteArray> SourceWriteBack::replay(const ApplicationDomain::Mail &, Sink::Operation, const QByteArray &) | 134 | KAsync::Job<QByteArray> SourceWriteBack::replay(const ApplicationDomain::Mail &, Sink::Operation, const QByteArray &, const QList<QByteArray> &) |
129 | { | 135 | { |
130 | return KAsync::null<QByteArray>(); | 136 | return KAsync::null<QByteArray>(); |
131 | } | 137 | } |
132 | 138 | ||
133 | KAsync::Job<QByteArray> SourceWriteBack::replay(const ApplicationDomain::Folder &, Sink::Operation, const QByteArray &) | 139 | KAsync::Job<QByteArray> SourceWriteBack::replay(const ApplicationDomain::Folder &, Sink::Operation, const QByteArray &, const QList<QByteArray> &) |
134 | { | 140 | { |
135 | return KAsync::null<QByteArray>(); | 141 | return KAsync::null<QByteArray>(); |
136 | } | 142 | } |