diff options
author | Milan Crha <mcrha@redhat.com> | 2013-08-08 13:48:19 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2013-08-08 13:48:19 +0800 |
commit | 52a48c15e0972e8bc7da95fd26d6cb299b6ab111 (patch) | |
tree | 254acd6cbe26ba2a03eee2ad3e7046e64b0c2a6d | |
parent | c8f9a064a64090b854792adbbcae816cebdea55e (diff) | |
download | gsoc2013-evolution-52a48c15e0972e8bc7da95fd26d6cb299b6ab111.tar gsoc2013-evolution-52a48c15e0972e8bc7da95fd26d6cb299b6ab111.tar.gz gsoc2013-evolution-52a48c15e0972e8bc7da95fd26d6cb299b6ab111.tar.bz2 gsoc2013-evolution-52a48c15e0972e8bc7da95fd26d6cb299b6ab111.tar.lz gsoc2013-evolution-52a48c15e0972e8bc7da95fd26d6cb299b6ab111.tar.xz gsoc2013-evolution-52a48c15e0972e8bc7da95fd26d6cb299b6ab111.tar.zst gsoc2013-evolution-52a48c15e0972e8bc7da95fd26d6cb299b6ab111.zip |
Bug #705446 - Old POP3 mails can be removed before getting them
-rw-r--r-- | libemail-engine/mail-ops.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/libemail-engine/mail-ops.c b/libemail-engine/mail-ops.c index 64ef0654ae..4f3dbd3ee1 100644 --- a/libemail-engine/mail-ops.c +++ b/libemail-engine/mail-ops.c @@ -352,7 +352,7 @@ fetch_mail_exec (struct _fetch_mail_msg *m, g_object_ref (fm->destination); } - if (!local_error) { + if (!local_error && !g_cancellable_is_cancelled (cancellable)) { folder_uids = camel_folder_get_uids (folder); cache_uids = camel_uid_cache_get_new_uids (cache, folder_uids); @@ -377,11 +377,26 @@ fetch_mail_exec (struct _fetch_mail_msg *m, g_cancellable_reset (m->cancellable); if (!success) { + GPtrArray *uncached_uids; + GHashTable *uncached_hash; + + uncached_uids = camel_folder_get_uncached_uids (folder, cache_uids, NULL); + uncached_hash = g_hash_table_new (g_str_hash, g_str_equal); + + for (i = 0; uncached_uids && i < uncached_uids->len; i++) { + g_hash_table_insert (uncached_hash, uncached_uids->pdata[i], uncached_uids->pdata[i]); + } + /* re-enter known UIDs, thus they are not * re-fetched next time */ for (i = 0; i < cache_uids->len; i++) { - camel_uid_cache_save_uid (cache, cache_uids->pdata[i]); + /* skip uncached UIDs */ + if (!g_hash_table_lookup (uncached_hash, cache_uids->pdata[i])) + camel_uid_cache_save_uid (cache, cache_uids->pdata[i]); } + + g_hash_table_destroy (uncached_hash); + camel_folder_free_uids (folder, uncached_uids); } /* save the cache of uids that we've just downloaded */ @@ -437,9 +452,18 @@ exit: /* also disconnect if not a local delivery mbox; * there is no need to keep the connection alive forever */ - if (!is_local_delivery) + if (!is_local_delivery) { + gboolean was_cancelled; + + was_cancelled = g_cancellable_is_cancelled (cancellable); + + /* pity, but otherwise it doesn't disconnect */ + if (was_cancelled) + g_cancellable_reset (cancellable); + camel_service_disconnect_sync ( - service, TRUE, cancellable, NULL); + service, !was_cancelled, cancellable, NULL); + } g_object_unref (session); } |