From 984eeab5718810e976b23f5b9c52c7fc9d8e023c Mon Sep 17 00:00:00 2001 From: Damien Riegel Date: Sat, 18 Jun 2016 13:36:21 -0700 Subject: [PATCH] add imap_commit_message function 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 ff0a1ba0..5dcb2d68 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 917e9877..c8962e1a 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 ecbc1959..441e6a84 100644 --- a/mx.c +++ b/mx.c @@ -1357,8 +1357,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.40.0