From 2950d3231d1849881f3ed557797404d1c2c83f8e Mon Sep 17 00:00:00 2001 From: Christoph Hohmann Date: Thu, 20 Feb 2003 23:02:39 +0000 Subject: [PATCH] 0.8.10claws35 * src/imap.c IMAP UID fetch speedup using SEARCH Patch submitted by Simon 'corecode' Schubert * src/imap.c fix problem with UIDs in IMAP UID cache that no longer existed --- ChangeLog.claws | 12 +++++++++- configure.ac | 2 +- src/imap.c | 61 +++++++++++++++++++++++-------------------------- 3 files changed, 41 insertions(+), 34 deletions(-) diff --git a/ChangeLog.claws b/ChangeLog.claws index fa6bc16ad..a0d9cc4f2 100644 --- a/ChangeLog.claws +++ b/ChangeLog.claws @@ -1,9 +1,19 @@ +2003-02-20 [christoph] 0.8.10claws35 + + * src/imap.c + IMAP UID fetch speedup using SEARCH + + Patch submitted by Simon 'corecode' Schubert + + * src/imap.c + fix problem with UIDs in IMAP UID cache that no longer existed + 2003-02-20 [christoph] 0.8.10claws34 * src/imap.c * src/procheader.c * src/procheader.h - IMAP header fetch speedup + IMAP header fetch speedup (fetch only headers cached in MsgInfo) Patch submitted by Simon 'corecode' Schubert diff --git a/configure.ac b/configure.ac index 0554bdbdf..ef3ae416b 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ MINOR_VERSION=8 MICRO_VERSION=10 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=claws34 +EXTRA_VERSION=claws35 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION dnl set $target diff --git a/src/imap.c b/src/imap.c index 73f6505e1..872c84a55 100644 --- a/src/imap.c +++ b/src/imap.c @@ -3415,10 +3415,13 @@ gint imap_get_num_list(Folder *folder, FolderItem *_item, GSList **msgnum_list) { IMAPFolderItem *item = (IMAPFolderItem *)_item; IMAPSession *session; - gint ok, i, lastuid_old, nummsgs = 0, exists, resent, unseen, uid_val; + gint ok, lastuid_old, nummsgs = 0, exists, resent, unseen, uid_val; + gint msgnum; GPtrArray *argbuf; gchar *cmdbuf = NULL; gchar *dir; + gchar *uidlist; + gchar **p, **list; g_return_val_if_fail(folder != NULL, -1); g_return_val_if_fail(item != NULL, -1); @@ -3438,11 +3441,7 @@ gint imap_get_num_list(Folder *folder, FolderItem *_item, GSList **msgnum_list) return 0; argbuf = g_ptr_array_new(); - if(item->lastuid) { - cmdbuf = g_strdup_printf("UID FETCH %d:* (UID)", (item->lastuid + 1)); - } else { - cmdbuf = g_strdup("UID SEARCH ALL"); - } + cmdbuf = g_strdup_printf("UID SEARCH UID %d:*", item->lastuid + 1); imap_cmd_gen_send(SESSION(session)->sock, cmdbuf); g_free(cmdbuf); ok = imap_cmd_ok(SESSION(session)->sock, argbuf); @@ -3455,35 +3454,33 @@ gint imap_get_num_list(Folder *folder, FolderItem *_item, GSList **msgnum_list) lastuid_old = item->lastuid; *msgnum_list = g_slist_copy(item->uid_list); debug_print("Got %d uids from cache\n", g_slist_length(item->uid_list)); - for(i = 0; i < argbuf->len; i++) { - int ret, msgidx, msgnum; - if (!strncmp(g_ptr_array_index(argbuf, i), "SEARCH ", 7)) { - gchar **p, **list = g_strsplit(g_ptr_array_index(argbuf, i) + 7, " ", 0); + if ((uidlist = search_array_str(argbuf, "SEARCH ")) != NULL) { + list = g_strsplit(uidlist + 7, " ", 0); + for (p = list; *p != NULL; ++p) { + if (sscanf(*p, "%d", &msgnum) == 1 && msgnum > lastuid_old) { + *msgnum_list = g_slist_prepend(*msgnum_list, GINT_TO_POINTER(msgnum)); + item->uid_list = g_slist_prepend(item->uid_list, GINT_TO_POINTER(msgnum)); + nummsgs++; + + if(msgnum > item->lastuid) + item->lastuid = msgnum; + } + } + g_strfreev(list); + } + + if (g_slist_length(item->uid_list) != exists) { + /* Cache contains more messages then folder, we have cached + an old UID of a message that was removed */ + debug_print("Freeing imap uid cache"); + item->lastuid = 0; + g_slist_free(item->uid_list); + item->uid_list = NULL; - for (p = list; *p != NULL; ++p) - if (sscanf(*p, "%d", &msgnum) == 1 && msgnum > lastuid_old) { - *msgnum_list = g_slist_prepend(*msgnum_list, GINT_TO_POINTER(msgnum)); - item->uid_list = g_slist_prepend(item->uid_list, GINT_TO_POINTER(msgnum)); - nummsgs++; - - if(msgnum > item->lastuid) - item->lastuid = msgnum; - } + g_slist_free(*msgnum_list); - g_strfreev(list); - - } else if((ret = sscanf(g_ptr_array_index(argbuf, i), - "%d FETCH (UID %d)", &msgidx, &msgnum)) == 2 && - msgnum > lastuid_old) { - *msgnum_list = g_slist_prepend(*msgnum_list, GINT_TO_POINTER(msgnum)); - item->uid_list = g_slist_prepend(item->uid_list, GINT_TO_POINTER(msgnum)); - nummsgs++; - - if(msgnum > item->lastuid) - item->lastuid = msgnum; - } - + return imap_get_num_list(folder, _item, msgnum_list); } dir = folder_item_get_path((FolderItem *)item); -- 2.25.1