[balsa/56-imap-expunge] mailbox-imap: Try to avoid critical messages



commit bffa0b61d8baef407145375a3ea8c5d4c246e8c8
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Tue Mar 9 19:22:31 2021 -0500

    mailbox-imap: Try to avoid critical messages
    
    * libbalsa/mailbox_imap.c
      (imap_expunge_idle): handle expunged messages in the order they are expunged;
      (libbalsa_mailbox_imap_fetch_headers): avoid a critical message.

 ChangeLog               |  9 +++++++++
 libbalsa/mailbox_imap.c | 11 ++++++-----
 2 files changed, 15 insertions(+), 5 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 19a6d28c8..ea723e8dd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2021-03-09  Peter Bloomfield  <pbloomfield bellsouth net>
+
+       Try to avoid critical messages
+
+       * libbalsa/mailbox_imap.c
+         (imap_expunge_idle): handle expunged messages in the order
+           they are expunged;
+         (libbalsa_mailbox_imap_fetch_headers): avoid a critical message.
+
 2021-03-08  Peter Bloomfield  <pbloomfield bellsouth net>
 
        Remove a scheduled idle callback at close time instead of at
diff --git a/libbalsa/mailbox_imap.c b/libbalsa/mailbox_imap.c
index c8a8eda4c..ce50379fc 100644
--- a/libbalsa/mailbox_imap.c
+++ b/libbalsa/mailbox_imap.c
@@ -908,11 +908,8 @@ imap_expunge_idle(gpointer user_data)
 
     libbalsa_lock_mailbox(mailbox);
 
-    /* Process the expunged messages in reverse order, so that each
-     * seqno points to the correct msg_info. */
-    g_array_sort(mimap->expunged_seqnos, cmp_msgno);
-    for (j = mimap->expunged_seqnos->len; j > 0; --j) {
-        guint seqno = g_array_index(mimap->expunged_seqnos, guint, j - 1);
+    for (j = 0; j < mimap->expunged_seqnos->len; j++) {
+        guint seqno = g_array_index(mimap->expunged_seqnos, guint, j);
         struct message_info *msg_info;
         guint i;
 
@@ -2331,6 +2328,10 @@ libbalsa_mailbox_imap_fetch_headers(LibBalsaMailbox *mailbox,
     glong msgno;
 
     msgno = libbalsa_message_get_msgno(message);
+    /* If message numbers are out of sync with the mail store,
+     * just skip the message: */
+    if (msgno > imap_mbox_handle_get_exists(mimap->handle))
+        return;
 
     II(rc,mimap->handle,
        imap_mbox_handle_fetch_range(mimap->handle, msgno, msgno,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]