* Actually parse a maildir message. This may also be used to fill
* out a fake header structure generated by lazy maildir parsing.
*/
-static HEADER *maildir_parse_message (int magic, const char *fname,
+HEADER *maildir_parse_message (int magic, const char *fname,
int is_old, HEADER * _h)
{
FILE *f;
{
if (hdr)
mutt_str_replace (&hdr->path, path);
+ mutt_str_replace (&msg->commited_path, full);
FREE (&msg->path);
/*
{
if (hdr)
mutt_str_replace (&hdr->path, tmp);
+ mutt_str_replace (&msg->commited_path, path);
FREE (&msg->path);
break;
}
return (0);
}
-int mh_sync_mailbox (CONTEXT * ctx, int *index_hint)
-{
- char path[_POSIX_PATH_MAX], tmp[_POSIX_PATH_MAX];
- int i, j;
#if USE_HCACHE
- header_cache_t *hc = NULL;
-#endif /* USE_HCACHE */
- char msgbuf[STRING];
- progress_t progress;
-
- if (ctx->magic == M_MH)
- i = mh_check_mailbox (ctx, index_hint);
- else
- i = maildir_check_mailbox (ctx, index_hint);
-
- if (i != 0)
- return i;
-
-#if USE_HCACHE
- if (ctx->magic == M_MAILDIR || ctx->magic == M_MH)
- hc = mutt_hcache_open(HeaderCache, ctx->path, NULL);
-#endif /* USE_HCACHE */
-
- if (!ctx->quiet)
- {
- snprintf (msgbuf, sizeof (msgbuf), _("Writing %s..."), ctx->path);
- mutt_progress_init (&progress, msgbuf, M_PROGRESS_MSG, WriteInc, ctx->msgcount);
- }
-
- for (i = 0; i < ctx->msgcount; i++)
- {
- if (!ctx->quiet)
- mutt_progress_update (&progress, i, -1);
+int mh_sync_mailbox_message (CONTEXT * ctx, int msgno, header_cache_t *hc)
+#else
+int mh_sync_mailbox_message (CONTEXT * ctx, int msgno)
+#endif
+{
+ char path[_POSIX_PATH_MAX], tmp[_POSIX_PATH_MAX];
+ HEADER *h = ctx->hdrs[msgno];
- if (ctx->hdrs[i]->deleted
- && (ctx->magic != M_MAILDIR || !option (OPTMAILDIRTRASH)))
+ if (h->deleted && (ctx->magic != M_MAILDIR || !option (OPTMAILDIRTRASH)))
{
- snprintf (path, sizeof (path), "%s/%s", ctx->path, ctx->hdrs[i]->path);
+ snprintf (path, sizeof (path), "%s/%s", ctx->path, h->path);
if (ctx->magic == M_MAILDIR
|| (option (OPTMHPURGE) && ctx->magic == M_MH))
{
#if USE_HCACHE
- if (ctx->magic == M_MAILDIR)
- mutt_hcache_delete (hc, ctx->hdrs[i]->path + 3, &maildir_hcache_keylen);
- else if (ctx->magic == M_MH)
- mutt_hcache_delete (hc, ctx->hdrs[i]->path, strlen);
+ if (hc) {
+ if (ctx->magic == M_MAILDIR)
+ mutt_hcache_delete (hc, h->path + 3, &maildir_hcache_keylen);
+ else if (ctx->magic == M_MH)
+ mutt_hcache_delete (hc, h->path, strlen);
+ }
#endif /* USE_HCACHE */
unlink (path);
}
else if (ctx->magic == M_MH)
{
/* MH just moves files out of the way when you delete them */
- if (*ctx->hdrs[i]->path != ',')
+ if (*h->path != ',')
{
- snprintf (tmp, sizeof (tmp), "%s/,%s", ctx->path,
- ctx->hdrs[i]->path);
+ snprintf (tmp, sizeof (tmp), "%s/,%s", ctx->path, h->path);
unlink (tmp);
rename (path, tmp);
}
}
}
- else if (ctx->hdrs[i]->changed || ctx->hdrs[i]->attach_del ||
+ else if (h->changed || h->attach_del ||
(ctx->magic == M_MAILDIR
- && (option (OPTMAILDIRTRASH) || ctx->hdrs[i]->trash)
- && (ctx->hdrs[i]->deleted != ctx->hdrs[i]->trash)))
+ && (option (OPTMAILDIRTRASH) || h->trash)
+ && (h->deleted != h->trash)))
{
if (ctx->magic == M_MAILDIR)
{
- if (maildir_sync_message (ctx, i) == -1)
- goto err;
+ if (maildir_sync_message (ctx, msgno) == -1)
+ return -1;
}
else
{
- if (mh_sync_message (ctx, i) == -1)
- goto err;
+ if (mh_sync_message (ctx, msgno) == -1)
+ return -1;
}
}
#if USE_HCACHE
- if (ctx->hdrs[i]->changed)
+ if (hc && h->changed)
{
if (ctx->magic == M_MAILDIR)
- mutt_hcache_store (hc, ctx->hdrs[i]->path + 3, ctx->hdrs[i],
- 0, &maildir_hcache_keylen, M_GENERATE_UIDVALIDITY);
+ mutt_hcache_store (hc, h->path + 3, h, 0, &maildir_hcache_keylen, M_GENERATE_UIDVALIDITY);
else if (ctx->magic == M_MH)
- mutt_hcache_store (hc, ctx->hdrs[i]->path, ctx->hdrs[i], 0, strlen, M_GENERATE_UIDVALIDITY);
+ mutt_hcache_store (hc, h->path, h, 0, strlen, M_GENERATE_UIDVALIDITY);
}
#endif
+ return 0;
+}
+
+int mh_sync_mailbox (CONTEXT * ctx, int *index_hint)
+{
+ int i, j;
+#if USE_HCACHE
+ header_cache_t *hc = NULL;
+#endif /* USE_HCACHE */
+ char msgbuf[STRING];
+ progress_t progress;
+
+ if (ctx->magic == M_MH)
+ i = mh_check_mailbox (ctx, index_hint);
+ else
+ i = maildir_check_mailbox (ctx, index_hint);
+
+ if (i != 0)
+ return i;
+
+#if USE_HCACHE
+ if (ctx->magic == M_MAILDIR || ctx->magic == M_MH)
+ hc = mutt_hcache_open(HeaderCache, ctx->path, NULL);
+#endif /* USE_HCACHE */
+
+ if (!ctx->quiet)
+ {
+ snprintf (msgbuf, sizeof (msgbuf), _("Writing %s..."), ctx->path);
+ mutt_progress_init (&progress, msgbuf, M_PROGRESS_MSG, WriteInc, ctx->msgcount);
+ }
+
+ for (i = 0; i < ctx->msgcount; i++)
+ {
+ if (!ctx->quiet)
+ mutt_progress_update (&progress, i, -1);
+
+#if USE_HCACHE
+ if (mh_sync_mailbox_message (ctx, i, hc) == -1)
+ goto err;
+#else
+ if (mh_sync_mailbox_message (ctx, i) == -1)
+ goto err;
+#endif
}
#if USE_HCACHE