diff options
Diffstat (limited to 'camel/providers/imap')
-rw-r--r-- | camel/providers/imap/camel-imap-folder.c | 63 |
1 files changed, 33 insertions, 30 deletions
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. |