diff options
Diffstat (limited to 'examples/imapresource/imapresource.cpp')
-rw-r--r-- | examples/imapresource/imapresource.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/examples/imapresource/imapresource.cpp b/examples/imapresource/imapresource.cpp index 6607578..e8bc903 100644 --- a/examples/imapresource/imapresource.cpp +++ b/examples/imapresource/imapresource.cpp | |||
@@ -246,10 +246,23 @@ public: | |||
246 | SinkWarningCtx(mLogCtx) << "Invalid folder " << folderRemoteId << folder.path(); | 246 | SinkWarningCtx(mLogCtx) << "Invalid folder " << folderRemoteId << folder.path(); |
247 | return KAsync::error<void>("Invalid folder"); | 247 | return KAsync::error<void>("Invalid folder"); |
248 | } | 248 | } |
249 | // auto capabilities = imap->getCapabilities(); | ||
250 | 249 | ||
251 | //First we fetch flag changes for all messages. Since we don't know which messages are locally available we just get everything and only apply to what we have. | 250 | //Start by checking if UIDVALIDITY is still correct |
252 | return KAsync::start<void>([=]() { | 251 | return KAsync::start([=] { |
252 | bool ok = false; | ||
253 | const auto uidvalidity = syncStore().readValue(folderRemoteId, "uidvalidity").toLongLong(&ok); | ||
254 | return imap->select(folder) | ||
255 | .then([=](const SelectResult &selectResult) { | ||
256 | SinkLogCtx(mLogCtx) << "Checking UIDVALIDITY. Local" << uidvalidity << "remote " << selectResult.uidValidity; | ||
257 | if (ok && selectResult.uidValidity != uidvalidity) { | ||
258 | SinkWarningCtx(mLogCtx) << "UIDVALIDITY changed " << selectResult.uidValidity << uidvalidity; | ||
259 | syncStore().removePrefix(folderRemoteId); | ||
260 | } | ||
261 | syncStore().writeValue(folderRemoteId, "uidvalidity", QByteArray::number(selectResult.uidValidity)); | ||
262 | }); | ||
263 | }) | ||
264 | // //First we fetch flag changes for all messages. Since we don't know which messages are locally available we just get everything and only apply to what we have. | ||
265 | .then([=] { | ||
253 | auto uidNext = syncStore().readValue(folderRemoteId, "uidnext").toLongLong(); | 266 | auto uidNext = syncStore().readValue(folderRemoteId, "uidnext").toLongLong(); |
254 | bool ok = false; | 267 | bool ok = false; |
255 | const auto changedsince = syncStore().readValue(folderRemoteId, "changedsince").toLongLong(&ok); | 268 | const auto changedsince = syncStore().readValue(folderRemoteId, "changedsince").toLongLong(&ok); |