]> granicus.if.org Git - mutt/commitdiff
fsync maildir/mh messages on commit. Closes #2962.
authorBrendan Cully <brendan@kublai.com>
Thu, 26 Jun 2008 07:18:02 +0000 (00:18 -0700)
committerBrendan Cully <brendan@kublai.com>
Thu, 26 Jun 2008 07:18:02 +0000 (00:18 -0700)
mh.c

diff --git a/mh.c b/mh.c
index e020d0b9b7b0ca082c9afce4c70efc0ad673b6f3..df55dd204978de8d4dec1be7acdc86e911902243 100644 (file)
--- a/mh.c
+++ b/mh.c
@@ -1311,6 +1311,11 @@ int maildir_commit_message (CONTEXT * ctx, MESSAGE * msg, HEADER * hdr)
   char full[_POSIX_PATH_MAX];
   char *s;
 
+  if (msg->fp && fsync(fileno(msg->fp)) < 0)
+  {
+    mutt_perror("Could not flush message to disk");
+    return -1;
+  }
   if (safe_fclose (&msg->fp) != 0)
     return -1;
 
@@ -1386,6 +1391,11 @@ static int _mh_commit_message (CONTEXT * ctx, MESSAGE * msg, HEADER * hdr,
   char path[_POSIX_PATH_MAX];
   char tmp[16];
 
+  if (msg->fp && fsync(fileno(msg->fp)) < 0)
+  {
+    mutt_perror("Could not flush message to disk");
+    return -1;
+  }
   if (safe_fclose (&msg->fp) != 0)
     return -1;