Move IMAP operations that were done in mx_commit_message to a dedicated
imap_commit_message function.
---
 imap/imap.h    |  1 +
 imap/message.c | 10 ++++++++++
 mx.c           |  3 +--
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/imap/imap.h b/imap/imap.h
index dbbaf92..7c8736f 100644
--- a/imap/imap.h
+++ b/imap/imap.h
@@ -58,6 +58,7 @@ int imap_mailbox_rename (const char* mailbox);
 /* message.c */
 int imap_append_message (CONTEXT* ctx, MESSAGE* msg);
 int imap_copy_messages (CONTEXT* ctx, HEADER* h, char* dest, int delete);
+int imap_commit_message (CONTEXT *ctx, MESSAGE *msg);
 
 /* socket.c */
 void imap_logout_all (void);
diff --git a/imap/message.c b/imap/message.c
index 917e987..c8962e1 100644
--- a/imap/message.c
+++ b/imap/message.c
@@ -600,6 +600,16 @@ int imap_close_message (CONTEXT *ctx, MESSAGE *msg)
   return safe_fclose (&msg->fp);
 }
 
+int imap_commit_message (CONTEXT *ctx, MESSAGE *msg)
+{
+  int r = safe_fclose (&msg->fp);
+
+  if (r)
+    return r;
+
+  return imap_append_message (ctx, msg);
+}
+
 int imap_append_message (CONTEXT *ctx, MESSAGE *msg)
 {
   IMAP_DATA* idata;
diff --git a/mx.c b/mx.c
index 0788e1c..224efe5 100644
--- a/mx.c
+++ b/mx.c
@@ -1360,8 +1360,7 @@ int mx_commit_message (MESSAGE *msg, CONTEXT *ctx)
 #ifdef USE_IMAP
     case MUTT_IMAP:
     {
-      if ((r = safe_fclose (&msg->fp)) == 0)
-       r = imap_append_message (ctx, msg);
+      r = imap_commit_message (ctx, msg);
       break;
     }
 #endif
-- 
2.8.3

Reply via email to