Commit ed5e3809 authored by Thomas Roessler's avatar Thomas Roessler

Mail folder synchronization-related fixes:

- Another situation under which mutt would lose track of the current
  message when maildir folders changed has been removed.

- While synchronizing mbox-type folders, a write error when
  constructing the draft version of the new mail folder would leave
  behind a copy ofthe file containing the draft.  This is most
  annoying if the write error is due to lack of disk space.
parent 9f3ca097
......@@ -717,7 +717,10 @@ int mbox_sync_mailbox (CONTEXT *ctx)
(fp = fdopen (i, "w")) == NULL)
{
if (-1 != i)
{
close (i);
unlink (tempfile);
}
mutt_error _("Could not create temporary file!");
goto bail;
}
......@@ -737,6 +740,7 @@ int mbox_sync_mailbox (CONTEXT *ctx)
mutt_error _("sync: mbox modified, but no modified messages! (report this bug)");
sleep(5); /* the mutt_error /will/ get cleared! */
dprint(1, (debugfile, "mbox_sync_mailbox(): no modified messages.\n"));
unlink (tempfile);
goto bail;
}
......@@ -768,12 +772,19 @@ int mbox_sync_mailbox (CONTEXT *ctx)
if (ctx->magic == M_MMDF)
{
if (fputs (MMDF_SEP, fp) == EOF)
{
unlink (tempfile);
goto bail;
}
}
else if (ctx->magic == M_KENDRA)
{
if (fputs (KENDRA_SEP, fp) == EOF)
{
unlink (tempfile);
goto bail;
}
}
/* save the new offset for this message. we add `offset' because the
......@@ -783,7 +794,10 @@ int mbox_sync_mailbox (CONTEXT *ctx)
newOffset[i - first].hdr = ftell (fp) + offset;
if (mutt_copy_message (fp, ctx, ctx->hdrs[i], M_CM_UPDATE, CH_FROM | CH_UPDATE | CH_UPDATE_LEN) == -1)
{
unlink (tempfile);
goto bail;
}
/* Since messages could have been deleted, the offsets stored in memory
* will be wrong, so update what we can, which is the offset of this
......@@ -797,13 +811,25 @@ int mbox_sync_mailbox (CONTEXT *ctx)
switch(ctx->magic)
{
case M_MMDF:
if(fputs(MMDF_SEP, fp) == EOF) goto bail;
if(fputs(MMDF_SEP, fp) == EOF)
{
unlink (tempfile);
goto bail;
}
break;
case M_KENDRA:
if(fputs(KENDRA_SEP, fp) == EOF) goto bail;
if(fputs(KENDRA_SEP, fp) == EOF)
{
unlink (tempfile);
goto bail;
}
break;
default:
if(fputs("\n", fp) == EOF) goto bail;
if(fputs("\n", fp) == EOF)
{
unlink (tempfile);
goto bail;
}
}
}
}
......
......@@ -533,13 +533,16 @@ int mh_sync_mailbox (CONTEXT * ctx)
int i, rc = 0;
i = mh_check_mailbox(ctx, NULL);
#if 0
if(i == M_REOPENED || i == M_NEW_MAIL)
{
set_option(OPTSORTCOLLAPSE);
mutt_sort_headers(ctx, (i == M_REOPENED));
unset_option(OPTSORTCOLLAPSE);
}
#endif
if(i == M_REOPENED || i == M_NEW_MAIL || i < 0)
return i;
......
......@@ -677,6 +677,7 @@ static int sync_mailbox (CONTEXT *ctx)
if (!ctx->quiet)
mutt_message (_("Writing %s..."), ctx->path);
switch (ctx->magic)
{
case M_MBOX:
......@@ -699,6 +700,9 @@ static int sync_mailbox (CONTEXT *ctx)
#endif /* USE_IMAP */
}
if (!ctx->quiet && rc == -1)
mutt_error ( _("Could not synchronize mailbox %s!"), ctx->path);
#ifdef BUFFY_SIZE
if (tmp && tmp->new == 0)
mutt_update_mailbox (tmp);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment