# HG changeset patch
# User Damien Riegel <[email protected]>
# Date 1465340534 14400
#      Tue Jun 07 19:02:14 2016 -0400
# Node ID 2b64e02c7d5760a0747ff5d2605f5a6af5388617
# Parent  9eebf8f22c4d6e1109e84aec5b528219cfa96051
move mutt_update_mailbox in mbox_sync_mailbox

mutt_update_mailbox is executed only when we call mbox_sync_mailbox.
Moving it inside this function makes 'sync_mailbox' code simpler and
easier to factorize.

diff -r 9eebf8f22c4d -r 2b64e02c7d57 mbox.c
--- a/mbox.c    Tue Jun 07 18:41:40 2016 -0400
+++ b/mbox.c    Tue Jun 07 19:02:14 2016 -0400
@@ -28,6 +28,7 @@
 #include "sort.h"
 #include "copy.h"
 #include "mutt_curses.h"
+#include "buffy.h"
 
 #include <sys/stat.h>
 #include <dirent.h>
@@ -782,6 +783,7 @@
   FILE *fp = NULL;
   progress_t progress;
   char msgbuf[STRING];
+  BUFFY *tmp = NULL;
 
   /* sort message by their position in the mailbox on disk */
   if (Sort != SORT_ORDER)
@@ -1079,6 +1081,12 @@
   unlink (tempfile); /* remove partial copy of the mailbox */
   mutt_unblock_signals ();
 
+  if (option(OPTCHECKMBOXSIZE))
+    tmp = mutt_find_mailbox (ctx->path);
+
+  if (tmp && tmp->new == 0)
+    mutt_update_mailbox (tmp);
+
   return (0); /* signal success */
 
 bail:  /* Come here in case of disaster */
diff -r 9eebf8f22c4d -r 2b64e02c7d57 mx.c
--- a/mx.c      Tue Jun 07 18:41:40 2016 -0400
+++ b/mx.c      Tue Jun 07 19:02:14 2016 -0400
@@ -756,7 +756,6 @@
 /* save changes to disk */
 static int sync_mailbox (CONTEXT *ctx, int *index_hint)
 {
-  BUFFY *tmp = NULL;
   int rc = -1;
 
   if (!ctx->quiet)
@@ -767,8 +766,6 @@
     case MUTT_MBOX:
     case MUTT_MMDF:
       rc = mbox_sync_mailbox (ctx, index_hint);
-      if (option(OPTCHECKMBOXSIZE))
-       tmp = mutt_find_mailbox (ctx->path);
       break;
       
     case MUTT_MH:
@@ -790,13 +787,6 @@
 #endif /* USE_POP */
   }
 
-#if 0
-  if (!ctx->quiet && !ctx->shutup && rc == -1)
-    mutt_error ( _("Could not synchronize mailbox %s!"), ctx->path);
-#endif
-  
-  if (tmp && tmp->new == 0)
-    mutt_update_mailbox (tmp);
   return rc;
 }
 

Reply via email to