Fix a bug in previous commit: don't check for deleted messages if there
authorDan Winship <danw@src.gnome.org>
Thu, 11 Jan 2001 22:50:10 +0000 (22:50 +0000)
committerDan Winship <danw@src.gnome.org>
Thu, 11 Jan 2001 22:50:10 +0000 (22:50 +0000)
* 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 ...").

camel/ChangeLog
camel/providers/imap/camel-imap-folder.c

index 9ce406f..3ceb41d 100644 (file)
@@ -1,6 +1,13 @@
 2001-01-11  Dan Winship  <danw@ximian.com>
 
        * 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  <danw@ximian.com>
+
+       * providers/imap/camel-imap-folder.c (camel_imap_folder_selected):
        New function to check for added/deleted messages when re-selecting
        a folder.
        (imap_refresh_info, imap_rescan, imap_update_summary): Various
index d3ba774..562b989 100644 (file)
@@ -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.