(fp = fdopen (i, "w")) == NULL)
{
if (-1 != i)
+ {
close (i);
+ unlink (tempfile);
+ }
mutt_error _("Could not create temporary file!");
goto bail;
}
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;
}
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
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
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;
+ }
}
}
}
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;
if (!ctx->quiet)
mutt_message (_("Writing %s..."), ctx->path);
+
switch (ctx->magic)
{
case M_MBOX:
#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);