diff options
Diffstat (limited to 'examples/maildirresource/maildirresource.cpp')
-rw-r--r-- | examples/maildirresource/maildirresource.cpp | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/examples/maildirresource/maildirresource.cpp b/examples/maildirresource/maildirresource.cpp index 7ac4b08..4505373 100644 --- a/examples/maildirresource/maildirresource.cpp +++ b/examples/maildirresource/maildirresource.cpp | |||
@@ -281,17 +281,19 @@ KAsync::Job<void> MaildirResource::replay(Sink::Storage &synchronizationStore, c | |||
281 | { | 281 | { |
282 | auto synchronizationTransaction = synchronizationStore.createTransaction(Sink::Storage::ReadWrite); | 282 | auto synchronizationTransaction = synchronizationStore.createTransaction(Sink::Storage::ReadWrite); |
283 | 283 | ||
284 | Sink::EntityBuffer buffer(value); | ||
285 | const Sink::Entity &entity = buffer.entity(); | ||
286 | const auto metadataBuffer = Sink::EntityBuffer::readBuffer<Sink::Metadata>(entity.metadata()); | ||
287 | Q_ASSERT(metadataBuffer); | ||
288 | if (!metadataBuffer->replayToSource()) { | ||
289 | Trace() << "Change is coming from the source"; | ||
290 | return KAsync::null<void>(); | ||
291 | } | ||
292 | const qint64 revision = metadataBuffer ? metadataBuffer->revision() : -1; | ||
293 | const auto operation = metadataBuffer ? metadataBuffer->operation() : Sink::Operation_Creation; | ||
294 | |||
284 | Trace() << "Replaying " << key << type; | 295 | Trace() << "Replaying " << key << type; |
285 | if (type == ENTITY_TYPE_FOLDER) { | 296 | if (type == ENTITY_TYPE_FOLDER) { |
286 | Sink::EntityBuffer buffer(value); | ||
287 | const Sink::Entity &entity = buffer.entity(); | ||
288 | const auto metadataBuffer = Sink::EntityBuffer::readBuffer<Sink::Metadata>(entity.metadata()); | ||
289 | if (metadataBuffer && !metadataBuffer->replayToSource()) { | ||
290 | Trace() << "Change is coming from the source"; | ||
291 | return KAsync::null<void>(); | ||
292 | } | ||
293 | const qint64 revision = metadataBuffer ? metadataBuffer->revision() : -1; | ||
294 | const auto operation = metadataBuffer ? metadataBuffer->operation() : Sink::Operation_Creation; | ||
295 | if (operation == Sink::Operation_Creation) { | 297 | if (operation == Sink::Operation_Creation) { |
296 | const Sink::ApplicationDomain::Folder folder(mResourceInstanceIdentifier, Sink::Storage::uidFromKey(key), revision, mFolderAdaptorFactory->createAdaptor(entity)); | 298 | const Sink::ApplicationDomain::Folder folder(mResourceInstanceIdentifier, Sink::Storage::uidFromKey(key), revision, mFolderAdaptorFactory->createAdaptor(entity)); |
297 | auto folderName = folder.getProperty("name").toString(); | 299 | auto folderName = folder.getProperty("name").toString(); |
@@ -315,15 +317,6 @@ KAsync::Job<void> MaildirResource::replay(Sink::Storage &synchronizationStore, c | |||
315 | Warning() << "Unkown operation" << operation; | 317 | Warning() << "Unkown operation" << operation; |
316 | } | 318 | } |
317 | } else if (type == ENTITY_TYPE_MAIL) { | 319 | } else if (type == ENTITY_TYPE_MAIL) { |
318 | Sink::EntityBuffer buffer(value); | ||
319 | const Sink::Entity &entity = buffer.entity(); | ||
320 | const auto metadataBuffer = Sink::EntityBuffer::readBuffer<Sink::Metadata>(entity.metadata()); | ||
321 | if (metadataBuffer && !metadataBuffer->replayToSource()) { | ||
322 | Trace() << "Change is coming from the source"; | ||
323 | return KAsync::null<void>(); | ||
324 | } | ||
325 | const qint64 revision = metadataBuffer ? metadataBuffer->revision() : -1; | ||
326 | const auto operation = metadataBuffer ? metadataBuffer->operation() : Sink::Operation_Creation; | ||
327 | if (operation == Sink::Operation_Creation) { | 320 | if (operation == Sink::Operation_Creation) { |
328 | const Sink::ApplicationDomain::Mail mail(mResourceInstanceIdentifier, Sink::Storage::uidFromKey(key), revision, mMailAdaptorFactory->createAdaptor(entity)); | 321 | const Sink::ApplicationDomain::Mail mail(mResourceInstanceIdentifier, Sink::Storage::uidFromKey(key), revision, mMailAdaptorFactory->createAdaptor(entity)); |
329 | auto parentFolder = mail.getProperty("folder").toByteArray(); | 322 | auto parentFolder = mail.getProperty("folder").toByteArray(); |