diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-06-30 15:13:10 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-06-30 15:13:10 +0200 |
commit | ef9a070c10dffc346b7dee0c7714d7bda7663017 (patch) | |
tree | 9b333451c2fdd42df1dd0d6a9586bd44573fbae5 /common | |
parent | ae20c6efd1051d48c367f97b96812f305b4d0819 (diff) | |
download | sink-ef9a070c10dffc346b7dee0c7714d7bda7663017.tar.gz sink-ef9a070c10dffc346b7dee0c7714d7bda7663017.zip |
Properly track changes applied by preprocessors
This is necessary so we get the actual changeset during replay,
so a mark-as-read action doesn't result in a new mime message, but only
the flag change.
Diffstat (limited to 'common')
-rw-r--r-- | common/bufferadaptor.h | 14 | ||||
-rw-r--r-- | common/pipeline.cpp | 5 |
2 files changed, 17 insertions, 2 deletions
diff --git a/common/bufferadaptor.h b/common/bufferadaptor.h index ad50582..2a40d18 100644 --- a/common/bufferadaptor.h +++ b/common/bufferadaptor.h | |||
@@ -82,15 +82,29 @@ public: | |||
82 | } | 82 | } |
83 | virtual void setProperty(const QByteArray &key, const QVariant &value) | 83 | virtual void setProperty(const QByteArray &key, const QVariant &value) |
84 | { | 84 | { |
85 | if (value != mValues.value(key)) { | ||
86 | mChanges << key; | ||
87 | } | ||
85 | mValues.insert(key, value); | 88 | mValues.insert(key, value); |
86 | } | 89 | } |
90 | |||
87 | virtual QByteArrayList availableProperties() const | 91 | virtual QByteArrayList availableProperties() const |
88 | { | 92 | { |
89 | return mValues.keys(); | 93 | return mValues.keys(); |
90 | } | 94 | } |
91 | 95 | ||
96 | void resetChangedProperties() | ||
97 | { | ||
98 | mChanges.clear(); | ||
99 | } | ||
100 | |||
101 | QList<QByteArray> changedProperties() const | ||
102 | { | ||
103 | return mChanges; | ||
104 | } | ||
92 | private: | 105 | private: |
93 | QHash<QByteArray, QVariant> mValues; | 106 | QHash<QByteArray, QVariant> mValues; |
107 | QList<QByteArray> mChanges; | ||
94 | }; | 108 | }; |
95 | } | 109 | } |
96 | } | 110 | } |
diff --git a/common/pipeline.cpp b/common/pipeline.cpp index 976a83f..c6d5297 100644 --- a/common/pipeline.cpp +++ b/common/pipeline.cpp | |||
@@ -305,7 +305,7 @@ KAsync::Job<qint64> Pipeline::modifiedEntity(void const *command, size_t size) | |||
305 | 305 | ||
306 | // Apply diff | 306 | // Apply diff |
307 | // FIXME only apply the properties that are available in the buffer | 307 | // FIXME only apply the properties that are available in the buffer |
308 | Trace() << "Applying changed properties: " << diff->availableProperties(); | 308 | Trace() << "Applying changed properties: " << changeset; |
309 | for (const auto &property : changeset) { | 309 | for (const auto &property : changeset) { |
310 | const auto value = diff->getProperty(property); | 310 | const auto value = diff->getProperty(property); |
311 | if (value.isValid()) { | 311 | if (value.isValid()) { |
@@ -320,6 +320,7 @@ KAsync::Job<qint64> Pipeline::modifiedEntity(void const *command, size_t size) | |||
320 | } | 320 | } |
321 | } | 321 | } |
322 | 322 | ||
323 | newAdaptor->resetChangedProperties(); | ||
323 | for (auto processor : d->processors[bufferType]) { | 324 | for (auto processor : d->processors[bufferType]) { |
324 | processor->modifiedEntity(key, Storage::maxRevision(d->transaction) + 1, *current, *newAdaptor, d->transaction); | 325 | processor->modifiedEntity(key, Storage::maxRevision(d->transaction) + 1, *current, *newAdaptor, d->transaction); |
325 | } | 326 | } |
@@ -330,7 +331,7 @@ KAsync::Job<qint64> Pipeline::modifiedEntity(void const *command, size_t size) | |||
330 | flatbuffers::FlatBufferBuilder metadataFbb; | 331 | flatbuffers::FlatBufferBuilder metadataFbb; |
331 | { | 332 | { |
332 | //We add availableProperties to account for the properties that have been changed by the preprocessors | 333 | //We add availableProperties to account for the properties that have been changed by the preprocessors |
333 | auto modifiedProperties = BufferUtils::toVector(metadataFbb, changeset + newAdaptor->availableProperties()); | 334 | auto modifiedProperties = BufferUtils::toVector(metadataFbb, changeset + newAdaptor->changedProperties()); |
334 | auto metadataBuilder = MetadataBuilder(metadataFbb); | 335 | auto metadataBuilder = MetadataBuilder(metadataFbb); |
335 | metadataBuilder.add_revision(newRevision); | 336 | metadataBuilder.add_revision(newRevision); |
336 | metadataBuilder.add_operation(Operation_Modification); | 337 | metadataBuilder.add_operation(Operation_Modification); |