From 95bd4f34290c59347534d70f05a7f0f909abcc15 Mon Sep 17 00:00:00 2001 From: Christoph Hohmann Date: Mon, 17 Mar 2003 18:57:51 +0000 Subject: [PATCH] 0.8.11claws24 * src/imap.c don't use recursion to fetch uids when the number of messages does not match. Moved code into subfunction that is used again when needed, to prevent an endless loop. --- ChangeLog.claws | 7 ++++ configure.ac | 2 +- src/imap.c | 103 ++++++++++++++++++++++++++++-------------------- 3 files changed, 68 insertions(+), 44 deletions(-) diff --git a/ChangeLog.claws b/ChangeLog.claws index 315926070..48a88479a 100644 --- a/ChangeLog.claws +++ b/ChangeLog.claws @@ -1,3 +1,10 @@ +2003-03-17 [christoph] 0.8.11claws24 + + * src/imap.c + don't use recursion to fetch uids when the number of messages + does not match. Moved code into subfunction that is used + again when needed, to prevent an endless loop. + 2003-03-17 [thorsten] 0.8.11claws23 * src/imageview.[ch] diff --git a/configure.ac b/configure.ac index 2c08180fe..30c0a0e41 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ MINOR_VERSION=8 MICRO_VERSION=11 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=claws23 +EXTRA_VERSION=claws24 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION dnl set $target diff --git a/src/imap.c b/src/imap.c index 451231ce6..e722ab5dd 100644 --- a/src/imap.c +++ b/src/imap.c @@ -3278,55 +3278,16 @@ static gboolean imap_rename_folder_func(GNode *node, gpointer data) return FALSE; } -gint imap_get_num_list(Folder *folder, FolderItem *_item, GSList **msgnum_list) +static gint get_list_of_uids(Folder *folder, IMAPFolderItem *item, GSList **msgnum_list) { - IMAPFolderItem *item = (IMAPFolderItem *)_item; + gint ok, nummsgs = 0, lastuid_old; IMAPSession *session; - gint ok, lastuid_old, nummsgs = 0, exists, recent, unseen, uid_val, uid_next; GSList *uidlist, *elem; - gchar *dir, *cmd_buf; - - g_return_val_if_fail(folder != NULL, -1); - g_return_val_if_fail(item != NULL, -1); - g_return_val_if_fail(item->item.path != NULL, -1); - g_return_val_if_fail(FOLDER_CLASS(folder) == &imap_class, -1); - g_return_val_if_fail(folder->account != NULL, -1); + gchar *cmd_buf; session = imap_session_get(folder); g_return_val_if_fail(session != NULL, -1); - ok = imap_status(session, IMAP_FOLDER(folder), item->item.path, - &exists, &recent, &uid_next, &uid_val, &unseen); - if (ok != IMAP_SUCCESS) - return -1; - - /* If old uid_next matches new uid_next we can be sure no message - was added to the folder */ - if (uid_next == item->uid_next) { - nummsgs = g_slist_length(item->uid_list); - - /* If number of messages is still the same we - know our caches message numbers are still valid, - otherwise if the number of messages has decrease - we discard our cache to start a new scan to find - out which numbers have been removed */ - if (exists == nummsgs) { - *msgnum_list = g_slist_copy(item->uid_list); - return nummsgs; - } else if (exists < nummsgs) { - debug_print("Freeing imap uid cache"); - item->lastuid = 0; - g_slist_free(item->uid_list); - item->uid_list = NULL; - } - } - item->uid_next = uid_next; - - if (exists == 0) { - *msgnum_list = NULL; - return 0; - } - ok = imap_select(session, IMAP_FOLDER(folder), item->item.path, NULL, NULL, NULL, NULL); if (ok != IMAP_SUCCESS) @@ -3389,6 +3350,60 @@ gint imap_get_num_list(Folder *folder, FolderItem *_item, GSList **msgnum_list) } g_slist_free(uidlist); + return nummsgs; +} + +gint imap_get_num_list(Folder *folder, FolderItem *_item, GSList **msgnum_list) +{ + IMAPFolderItem *item = (IMAPFolderItem *)_item; + IMAPSession *session; + gint ok, nummsgs = 0, exists, recent, unseen, uid_val, uid_next; + GSList *uidlist; + gchar *dir; + + g_return_val_if_fail(folder != NULL, -1); + g_return_val_if_fail(item != NULL, -1); + g_return_val_if_fail(item->item.path != NULL, -1); + g_return_val_if_fail(FOLDER_CLASS(folder) == &imap_class, -1); + g_return_val_if_fail(folder->account != NULL, -1); + + session = imap_session_get(folder); + g_return_val_if_fail(session != NULL, -1); + + ok = imap_status(session, IMAP_FOLDER(folder), item->item.path, + &exists, &recent, &uid_next, &uid_val, &unseen); + if (ok != IMAP_SUCCESS) + return -1; + + /* If old uid_next matches new uid_next we can be sure no message + was added to the folder */ + if (uid_next == item->uid_next) { + nummsgs = g_slist_length(item->uid_list); + + /* If number of messages is still the same we + know our caches message numbers are still valid, + otherwise if the number of messages has decrease + we discard our cache to start a new scan to find + out which numbers have been removed */ + if (exists == nummsgs) { + *msgnum_list = g_slist_copy(item->uid_list); + return nummsgs; + } else if (exists < nummsgs) { + debug_print("Freeing imap uid cache"); + item->lastuid = 0; + g_slist_free(item->uid_list); + item->uid_list = NULL; + } + } + item->uid_next = uid_next; + + if (exists == 0) { + *msgnum_list = NULL; + return 0; + } + + nummsgs = get_list_of_uids(folder, item, &uidlist); + if (nummsgs != exists) { /* Cache contains more messages then folder, we have cached an old UID of a message that was removed and new messages @@ -3401,9 +3416,11 @@ gint imap_get_num_list(Folder *folder, FolderItem *_item, GSList **msgnum_list) g_slist_free(*msgnum_list); - return imap_get_num_list(folder, _item, msgnum_list); + nummsgs = get_list_of_uids(folder, item, &uidlist); } + *msgnum_list = uidlist; + dir = folder_item_get_path((FolderItem *)item); debug_print("removing old messages from %s\n", dir); remove_numbered_files_not_in_list(dir, *msgnum_list); -- 2.25.1