summaryrefslogtreecommitdiffstats
path: root/mbox.c
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2016-11-13 20:02:35 -0800
committerKevin McCarthy <kevin@8t8.us>2016-11-13 20:02:35 -0800
commitd3705ea8b23de24a63a4b659ead18a0cf6fb756a (patch)
tree3d506dfe6056d7c085402c2b848a1fc0862120b5 /mbox.c
parentf46e648f568c38b57ada874cea87e561e3a235c7 (diff)
Create mx_ops.sync operation. Refactor compress to use the mx_ops.sync.
Change compress.sync_mailbox() to lock the compressed mailbox around both the tempfile sync and compress operations. This will prevent changes made inbetween the two syncs from being overwritten. Thanks to Damien Riegel for his original patch refactoring mx_ops.sync, which this patch is partially based upon.
Diffstat (limited to 'mbox.c')
-rw-r--r--mbox.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/mbox.c b/mbox.c
index 13fc3d62..37f426d8 100644
--- a/mbox.c
+++ b/mbox.c
@@ -802,7 +802,7 @@ void mbox_reset_atime (CONTEXT *ctx, struct stat *st)
* 0 success
* -1 failure
*/
-int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint)
+static int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint)
{
char tempfile[_POSIX_PATH_MAX];
char buf[32];
@@ -817,6 +817,7 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint)
FILE *fp = NULL;
progress_t progress;
char msgbuf[STRING];
+ BUFFY *tmp = NULL;
/* sort message by their position in the mailbox on disk */
if (Sort != SORT_ORDER)
@@ -1114,6 +1115,13 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint)
unlink (tempfile); /* remove partial copy of the mailbox */
mutt_unblock_signals ();
+ if (option(OPTCHECKMBOXSIZE))
+ {
+ tmp = mutt_find_mailbox (ctx->path);
+ if (tmp && tmp->new == 0)
+ mutt_update_mailbox (tmp);
+ }
+
return (0); /* signal success */
bail: /* Come here in case of disaster */
@@ -1354,6 +1362,7 @@ struct mx_ops mx_mbox_ops = {
.commit_msg = mbox_commit_message,
.open_new_msg = mbox_open_new_message,
.check = mbox_check_mailbox,
+ .sync = mbox_sync_mailbox,
};
struct mx_ops mx_mmdf_ops = {
@@ -1365,4 +1374,5 @@ struct mx_ops mx_mmdf_ops = {
.commit_msg = mmdf_commit_message,
.open_new_msg = mbox_open_new_message,
.check = mbox_check_mailbox,
+ .sync = mbox_sync_mailbox,
};