diff options
-rw-r--r-- | examples/imapresource/imapresource.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
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: | |||
63 | void updatedIndexedProperties(Sink::ApplicationDomain::BufferAdaptor &newEntity) | 63 | void updatedIndexedProperties(Sink::ApplicationDomain::BufferAdaptor &newEntity) |
64 | { | 64 | { |
65 | const auto mimeMessagePath = newEntity.getProperty("mimeMessage").toString(); | 65 | const auto mimeMessagePath = newEntity.getProperty("mimeMessage").toString(); |
66 | Trace() << "Updating indexed properties " << mimeMessagePath; | ||
66 | QFile f(mimeMessagePath); | 67 | QFile f(mimeMessagePath); |
67 | if (!f.open(QIODevice::ReadOnly)) { | 68 | if (!f.open(QIODevice::ReadOnly)) { |
68 | Warning() << "Failed to open the file: " << mimeMessagePath; | 69 | Warning() << "Failed to open the file: " << mimeMessagePath; |
@@ -178,10 +179,7 @@ public: | |||
178 | time->start(); | 179 | time->start(); |
179 | const QByteArray bufferType = ENTITY_TYPE_MAIL; | 180 | const QByteArray bufferType = ENTITY_TYPE_MAIL; |
180 | 181 | ||
181 | 182 | Trace() << "Importing new mail." << path; | |
182 | Trace() << "Importing new mail."; | ||
183 | |||
184 | // Trace() << "Looking into " << listingPath; | ||
185 | 183 | ||
186 | const auto folderLocalId = syncStore().resolveRemoteId(ENTITY_TYPE_FOLDER, path.toUtf8()); | 184 | const auto folderLocalId = syncStore().resolveRemoteId(ENTITY_TYPE_FOLDER, path.toUtf8()); |
187 | 185 | ||
@@ -195,14 +193,18 @@ public: | |||
195 | Sink::ApplicationDomain::Mail mail; | 193 | Sink::ApplicationDomain::Mail mail; |
196 | mail.setFolder(folderLocalId); | 194 | mail.setFolder(folderLocalId); |
197 | 195 | ||
198 | auto filePath = Sink::resourceStorageLocation(mResourceInstanceIdentifier) + "/" + remoteId; | 196 | const auto directory = Sink::resourceStorageLocation(mResourceInstanceIdentifier) + "/" + path.toUtf8(); |
199 | QDir().mkpath(Sink::resourceStorageLocation(mResourceInstanceIdentifier) + "/" + path.toUtf8()); | 197 | QDir().mkpath(directory); |
198 | auto filePath = directory + "/" + QByteArray::number(message.uid); | ||
200 | QFile file(filePath); | 199 | QFile file(filePath); |
201 | if (!file.open(QIODevice::WriteOnly)) { | 200 | if (!file.open(QIODevice::WriteOnly)) { |
202 | Warning() << "Failed to open file for writing: " << file.errorString(); | 201 | Warning() << "Failed to open file for writing: " << file.errorString(); |
203 | } | 202 | } |
204 | const auto content = message.msg->encodedContent(); | 203 | const auto content = message.msg->encodedContent(); |
205 | file.write(content); | 204 | file.write(content); |
205 | //Close before calling createOrModify, to ensure the file is available | ||
206 | file.close(); | ||
207 | |||
206 | mail.setMimeMessagePath(filePath); | 208 | mail.setMimeMessagePath(filePath); |
207 | mail.setUnread(!message.flags.contains(Imap::Flags::Seen)); | 209 | mail.setUnread(!message.flags.contains(Imap::Flags::Seen)); |
208 | mail.setImportant(message.flags.contains(Imap::Flags::Flagged)); | 210 | mail.setImportant(message.flags.contains(Imap::Flags::Flagged)); |