diff options
Diffstat (limited to 'examples/maildirresource/maildirresource.cpp')
-rw-r--r-- | examples/maildirresource/maildirresource.cpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/examples/maildirresource/maildirresource.cpp b/examples/maildirresource/maildirresource.cpp index 5a38b01..d0b663b 100644 --- a/examples/maildirresource/maildirresource.cpp +++ b/examples/maildirresource/maildirresource.cpp | |||
@@ -277,8 +277,27 @@ void MaildirResource::synchronizeMails(Akonadi2::Storage::Transaction &transacti | |||
277 | Akonadi2::Storage store(Akonadi2::storageLocation(), mResourceInstanceIdentifier + ".synchronization", Akonadi2::Storage::ReadWrite); | 277 | Akonadi2::Storage store(Akonadi2::storageLocation(), mResourceInstanceIdentifier + ".synchronization", Akonadi2::Storage::ReadWrite); |
278 | auto synchronizationTransaction = store.createTransaction(Akonadi2::Storage::ReadWrite); | 278 | auto synchronizationTransaction = store.createTransaction(Akonadi2::Storage::ReadWrite); |
279 | 279 | ||
280 | scanForRemovals(transaction, synchronizationTransaction, bufferType, [&listingPath](const QByteArray &remoteId) -> bool { | 280 | const auto folderLocalId = resolveRemoteId(ENTITY_TYPE_FOLDER, path, synchronizationTransaction); |
281 | return QFile(listingPath + QDir::separator() + remoteId).exists(); | 281 | |
282 | auto exists = [&listingPath](const QByteArray &remoteId) -> bool { | ||
283 | return QFile(listingPath + "/" + remoteId).exists(); | ||
284 | }; | ||
285 | |||
286 | auto property = "folder"; | ||
287 | Index index(bufferType + ".index." + property, transaction); | ||
288 | index.lookup(folderLocalId.toLatin1(), [&](const QByteArray &akonadiId) { | ||
289 | const auto remoteId = resolveLocalId(bufferType, akonadiId, synchronizationTransaction); | ||
290 | if (!remoteId.isEmpty()) { | ||
291 | if (!exists(remoteId.toLatin1())) { | ||
292 | Trace() << "Found a removed entity: " << akonadiId; | ||
293 | deleteEntity(akonadiId, Akonadi2::Storage::maxRevision(transaction), bufferType, [this](const QByteArray &buffer) { | ||
294 | enqueueCommand(mSynchronizerQueue, Akonadi2::Commands::DeleteEntityCommand, buffer); | ||
295 | }); | ||
296 | } | ||
297 | } | ||
298 | }, | ||
299 | [property](const Index::Error &error) { | ||
300 | Warning() << "Error in index: " << error.message << property; | ||
282 | }); | 301 | }); |
283 | 302 | ||
284 | while (entryIterator->hasNext()) { | 303 | while (entryIterator->hasNext()) { |
@@ -300,7 +319,7 @@ void MaildirResource::synchronizeMails(Akonadi2::Storage::Transaction &transacti | |||
300 | mail.setProperty("sender", msg->from(true)->asUnicodeString()); | 319 | mail.setProperty("sender", msg->from(true)->asUnicodeString()); |
301 | mail.setProperty("senderName", msg->from(true)->asUnicodeString()); | 320 | mail.setProperty("senderName", msg->from(true)->asUnicodeString()); |
302 | mail.setProperty("date", msg->date(true)->dateTime()); | 321 | mail.setProperty("date", msg->date(true)->dateTime()); |
303 | mail.setProperty("folder", resolveRemoteId(ENTITY_TYPE_FOLDER, path, synchronizationTransaction)); | 322 | mail.setProperty("folder", folderLocalId); |
304 | mail.setProperty("mimeMessage", filepath); | 323 | mail.setProperty("mimeMessage", filepath); |
305 | mail.setProperty("unread", !flags.testFlag(KPIM::Maildir::Seen)); | 324 | mail.setProperty("unread", !flags.testFlag(KPIM::Maildir::Seen)); |
306 | mail.setProperty("important", flags.testFlag(KPIM::Maildir::Flagged)); | 325 | mail.setProperty("important", flags.testFlag(KPIM::Maildir::Flagged)); |