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)
This commit is contained in:
Oswald Buddenhagen 2012-09-15 14:15:07 +02:00
parent df6c3b64b7
commit a326bf2f58

View File

@ -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