From a5d693e5b71caeb21d0337e93d62e49584ae6890 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 31 May 2016 18:13:21 +0200 Subject: Fixed property extraction in imap resource --- examples/imapresource/imapresource.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'examples') diff --git a/examples/imapresource/imapresource.cpp b/examples/imapresource/imapresource.cpp index 0e766d5..5e5aae6 100644 --- a/examples/imapresource/imapresource.cpp +++ b/examples/imapresource/imapresource.cpp @@ -63,6 +63,7 @@ public: void updatedIndexedProperties(Sink::ApplicationDomain::BufferAdaptor &newEntity) { const auto mimeMessagePath = newEntity.getProperty("mimeMessage").toString(); + Trace() << "Updating indexed properties " << mimeMessagePath; QFile f(mimeMessagePath); if (!f.open(QIODevice::ReadOnly)) { Warning() << "Failed to open the file: " << mimeMessagePath; @@ -178,10 +179,7 @@ public: time->start(); const QByteArray bufferType = ENTITY_TYPE_MAIL; - - Trace() << "Importing new mail."; - - // Trace() << "Looking into " << listingPath; + Trace() << "Importing new mail." << path; const auto folderLocalId = syncStore().resolveRemoteId(ENTITY_TYPE_FOLDER, path.toUtf8()); @@ -195,14 +193,18 @@ public: Sink::ApplicationDomain::Mail mail; mail.setFolder(folderLocalId); - auto filePath = Sink::resourceStorageLocation(mResourceInstanceIdentifier) + "/" + remoteId; - QDir().mkpath(Sink::resourceStorageLocation(mResourceInstanceIdentifier) + "/" + path.toUtf8()); + const auto directory = Sink::resourceStorageLocation(mResourceInstanceIdentifier) + "/" + path.toUtf8(); + QDir().mkpath(directory); + auto filePath = directory + "/" + QByteArray::number(message.uid); QFile file(filePath); if (!file.open(QIODevice::WriteOnly)) { Warning() << "Failed to open file for writing: " << file.errorString(); } const auto content = message.msg->encodedContent(); file.write(content); + //Close before calling createOrModify, to ensure the file is available + file.close(); + mail.setMimeMessagePath(filePath); mail.setUnread(!message.flags.contains(Imap::Flags::Seen)); mail.setImportant(message.flags.contains(Imap::Flags::Flagged)); -- cgit v1.2.3