From a974fb1de3f0d98def12d34baa15b83ad3a48eff Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Thu, 11 Jan 2001 22:50:10 +0000 Subject: Fix a bug in previous commit: don't check for deleted messages if there * providers/imap/camel-imap-folder.c (camel_imap_folder_selected): Fix a bug in previous commit: don't check for deleted messages if there are no known messages in the folder (because it would end up sending "FETCH 0 ..."). svn path=/trunk/; revision=7412 --- camel/ChangeLog | 7 ++++ camel/providers/imap/camel-imap-folder.c | 63 +++++++++++++++++--------------- 2 files changed, 40 insertions(+), 30 deletions(-) diff --git a/camel/ChangeLog b/camel/ChangeLog index 9ce406f2d8..3ceb41d676 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,10 @@ +2001-01-11 Dan Winship + + * providers/imap/camel-imap-folder.c (camel_imap_folder_selected): + Fix a bug in previous commit: don't check for deleted messages if + there are no known messages in the folder (because it would end up + sending "FETCH 0 ..."). + 2001-01-11 Dan Winship * providers/imap/camel-imap-folder.c (camel_imap_folder_selected): diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c index d3ba77478e..562b989057 100644 --- a/camel/providers/imap/camel-imap-folder.c +++ b/camel/providers/imap/camel-imap-folder.c @@ -237,37 +237,40 @@ camel_imap_folder_selected (CamelFolder *folder, CamelImapResponse *response, return; } - /* Similarly, if the UID of the highest message we know about - * has changed, then that indicates that messages have been - * both added and removed, so we have to rescan to find the - * removed ones. (We pass NULL for the folder since we know - * that this folder is selected, and we don't want - * camel_imap_command to worry about it.) - */ - response = camel_imap_command (CAMEL_IMAP_STORE (folder->parent_store), - NULL, ex, "FETCH %d UID", count); - if (!response) - return; - uid = 0; - for (i = 0; i < response->untagged->len; i++) { - resp = response->untagged->pdata[i]; - val = strtoul (resp + 2, &resp, 10); - if (val != count || g_strncasecmp (resp, " FETCH (", 8) != 0) - continue; - resp = e_strstrcase (resp, "UID "); - if (!resp) - continue; - uid = strtoul (resp + 4, NULL, 10); - break; - } - camel_imap_response_free (response); + if (count != 0) { + /* Similarly, if the UID of the highest message we + * know about has changed, then that indicates that + * messages have been both added and removed, so we + * have to rescan to find the removed ones. (We pass + * NULL for the folder since we know that this folder + * is selected, and we don't want camel_imap_command + * to worry about it.) + */ + response = camel_imap_command (CAMEL_IMAP_STORE (folder->parent_store), + NULL, ex, "FETCH %d UID", count); + if (!response) + return; + uid = 0; + for (i = 0; i < response->untagged->len; i++) { + resp = response->untagged->pdata[i]; + val = strtoul (resp + 2, &resp, 10); + if (val != count || g_strncasecmp (resp, " FETCH (", 8) != 0) + continue; + resp = e_strstrcase (resp, "UID "); + if (!resp) + continue; + uid = strtoul (resp + 4, NULL, 10); + break; + } + camel_imap_response_free (response); - info = camel_folder_summary_index (folder->summary, count - 1); - val = strtoul (camel_message_info_uid (info), NULL, 10); - camel_folder_summary_info_free (folder->summary, info); - if (uid == 0 || uid != val) { - imap_rescan (folder, exists, ex); - return; + info = camel_folder_summary_index (folder->summary, count - 1); + val = strtoul (camel_message_info_uid (info), NULL, 10); + camel_folder_summary_info_free (folder->summary, info); + if (uid == 0 || uid != val) { + imap_rescan (folder, exists, ex); + return; + } } /* OK. So now we know that no messages have been expunged. Whew. -- cgit v1.2.3