Browse Source

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)
Oswald Buddenhagen 12 years ago
parent
commit
a326bf2f58
1 changed files with 1 additions and 1 deletions
  1. 1 1
      src/drv_maildir.c

+ 1 - 1
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 );
 	ret = write( fd, data->data, data->len );
 	free( data->data );
 	free( data->data );
-	if (ret != data->len) {
+	if (ret != data->len || (ret = fsync( fd ))) {
 		if (ret < 0)
 		if (ret < 0)
 			sys_error( "Maildir error: cannot write %s", buf );
 			sys_error( "Maildir error: cannot write %s", buf );
 		else
 		else