From a326bf2f5890230fb31b982e39be9b80ad4fdecf Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Sat, 15 Sep 2012 14:15:07 +0200 Subject: [PATCH] avoid that a system crash can lose mails this fixes two possible failure scenarios: - if the journal is committed but the mails are not, the missing files would be erroneously interpreted as deletions which would be propagated - less seriously, if the mail files' meta data was committed but the file contents were not, we would end up with empty files, which would have to be re-fetched "behind mbsync's back" (just deleting the files would not work - see above) --- src/drv_maildir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/drv_maildir.c b/src/drv_maildir.c index 164f7b5..921f97f 100644 --- a/src/drv_maildir.c +++ b/src/drv_maildir.c @@ -1204,7 +1204,7 @@ maildir_store_msg( store_t *gctx, msg_data_t *data, int to_trash, } ret = write( fd, data->data, data->len ); free( data->data ); - if (ret != data->len) { + if (ret != data->len || (ret = fsync( fd ))) { if (ret < 0) sys_error( "Maildir error: cannot write %s", buf ); else