summaryrefslogtreecommitdiffstats
path: root/examples/imapresource/imapserverproxy.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-01-10 11:28:53 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-01-10 11:28:53 +0100
commit8e84c8a78b7e308cc2b09241af649851036d11de (patch)
treee4b8b964aa7400e9f1d88b04cadcabb423e039dd /examples/imapresource/imapserverproxy.cpp
parent5064e5c9a705365524321e01686e73ac1bdf28a0 (diff)
downloadsink-8e84c8a78b7e308cc2b09241af649851036d11de.tar.gz
sink-8e84c8a78b7e308cc2b09241af649851036d11de.zip
Improved imap mail sync algorithm.
* when requesting individual mails we sync the full content * when requesting individual folders we get 2 weeks of full content + headers for everything else. * when requesting a sync for all folders we only get 2 weeks of full content. Getting the headers for 50k messages takes about 180s on my system with kolabnow (network being the bottleneck), so that's managable. Getting the full content would take in the range of hours. This way we have something to show, and a way to request more data, without making the system overly complex yet. Certainly not the final solution, but a good start.
Diffstat (limited to 'examples/imapresource/imapserverproxy.cpp')
-rw-r--r--examples/imapresource/imapserverproxy.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/examples/imapresource/imapserverproxy.cpp b/examples/imapresource/imapserverproxy.cpp
index af1f4d1..a172c93 100644
--- a/examples/imapresource/imapserverproxy.cpp
+++ b/examples/imapresource/imapserverproxy.cpp
@@ -441,18 +441,18 @@ KAsync::Job<void> ImapServerProxy::fetchMessages(const Folder &folder, qint64 ui
441 SinkTrace() << " Total: " << uidsToFetch.size(); 441 SinkTrace() << " Total: " << uidsToFetch.size();
442 SinkTrace() << " Uids to fetch: " << uidsToFetch; 442 SinkTrace() << " Uids to fetch: " << uidsToFetch;
443 SinkTrace() << " Took: " << Sink::Log::TraceTime(time->elapsed()); 443 SinkTrace() << " Took: " << Sink::Log::TraceTime(time->elapsed());
444 return fetchMessages(folder, uidsToFetch, callback, progress); 444 return fetchMessages(folder, uidsToFetch, false, callback, progress);
445 }); 445 });
446 446
447 }); 447 });
448} 448}
449 449
450KAsync::Job<void> ImapServerProxy::fetchMessages(const Folder &folder, const QVector<qint64> &uidsToFetch, std::function<void(const Message &)> callback, std::function<void(int, int)> progress) 450KAsync::Job<void> ImapServerProxy::fetchMessages(const Folder &folder, const QVector<qint64> &uidsToFetch, bool headersOnly, std::function<void(const Message &)> callback, std::function<void(int, int)> progress)
451{ 451{
452 auto time = QSharedPointer<QTime>::create(); 452 auto time = QSharedPointer<QTime>::create();
453 time->start(); 453 time->start();
454 Q_ASSERT(!mPersonalNamespaceSeparator.isNull()); 454 Q_ASSERT(!mPersonalNamespaceSeparator.isNull());
455 return select(mailboxFromFolder(folder)).then<void, SelectResult>([this, callback, folder, time, progress, uidsToFetch](const SelectResult &selectResult) -> KAsync::Job<void> { 455 return select(mailboxFromFolder(folder)).then<void, SelectResult>([this, callback, folder, time, progress, uidsToFetch, headersOnly](const SelectResult &selectResult) -> KAsync::Job<void> {
456 456
457 SinkTrace() << "Fetching messages" << folder.path(); 457 SinkTrace() << "Fetching messages" << folder.path();
458 SinkTrace() << " Total: " << uidsToFetch.size(); 458 SinkTrace() << " Total: " << uidsToFetch.size();
@@ -467,7 +467,11 @@ KAsync::Job<void> ImapServerProxy::fetchMessages(const Folder &folder, const QVe
467 } 467 }
468 KIMAP2::FetchJob::FetchScope scope; 468 KIMAP2::FetchJob::FetchScope scope;
469 scope.parts.clear(); 469 scope.parts.clear();
470 scope.mode = KIMAP2::FetchJob::FetchScope::Full; 470 if (headersOnly) {
471 scope.mode = KIMAP2::FetchJob::FetchScope::Headers;
472 } else {
473 scope.mode = KIMAP2::FetchJob::FetchScope::Full;
474 }
471 475
472 KIMAP2::ImapSet set; 476 KIMAP2::ImapSet set;
473 set.add(uidsToFetch); 477 set.add(uidsToFetch);