]> granicus.if.org Git - neomutt/commitdiff
Restore Sort immediately after sorting by mailbox order in mbox_sync_mailbox.
authorBrendan Cully <brendan@kublai.com>
Mon, 1 Aug 2005 18:05:12 +0000 (18:05 +0000)
committerBrendan Cully <brendan@kublai.com>
Mon, 1 Aug 2005 18:05:12 +0000 (18:05 +0000)
(closes #972)

mbox.c

diff --git a/mbox.c b/mbox.c
index 6f721d2d2b99115e283c7a999e079971c3171444..81ad81dd280dfe4d4e33040c756188555f0f40d6 100644 (file)
--- a/mbox.c
+++ b/mbox.c
@@ -688,6 +688,8 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint)
     save_sort = Sort;
     Sort = SORT_ORDER;
     mutt_sort_headers (ctx, 0);
+    Sort = save_sort;
+    need_sort = 1;
   }
 
   /* need to open the file for writing in such a way that it does not truncate
@@ -718,11 +720,8 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint)
     goto bail;
   }
   else if (i < 0)
-  {
     /* fatal error */
-    Sort = save_sort;
     return (-1);
-  }
 
   /* Create a temporary file to write the new version of the mailbox in. */
   mutt_mktemp (tempfile);
@@ -951,7 +950,6 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint)
     mutt_unblock_signals ();
     mx_fastclose_mailbox (ctx);
     mutt_error _("Fatal error!  Could not reopen mailbox!");
-    Sort = save_sort;
     return (-1);
   }
 
@@ -970,7 +968,6 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint)
   FREE (&oldOffset);
   unlink (tempfile); /* remove partial copy of the mailbox */
   mutt_unblock_signals ();
-  Sort = save_sort; /* Restore the default value. */
 
   return (0); /* signal success */
 
@@ -1005,13 +1002,10 @@ bail:  /* Come here in case of disaster */
     return (-1);
   }
 
-  if (need_sort || save_sort != Sort)
-  {
-    Sort = save_sort;
+  if (need_sort)
     /* if the mailbox was reopened, the thread tree will be invalid so make
      * sure to start threading from scratch.  */
     mutt_sort_headers (ctx, (need_sort == M_REOPENED));
-  }
 
   return rc;
 }