summaryrefslogtreecommitdiffstats
path: root/mh.c
diff options
context:
space:
mode:
authorThomas Roessler <roessler@does-not-exist.org>1998-09-23 08:29:54 +0000
committerThomas Roessler <roessler@does-not-exist.org>1998-09-23 08:29:54 +0000
commit74e989216cfb9dff160c54ca12afae75cfd11a1b (patch)
tree1708610f2cce88046e749120f14c1d3680bab7e1 /mh.c
parent726ce750b4f9cec3236310b94612ebf22844fb49 (diff)
Correct the index_hint handling in mh_check_mailbox().
Diffstat (limited to 'mh.c')
-rw-r--r--mh.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/mh.c b/mh.c
index 305991da..f5a22061 100644
--- a/mh.c
+++ b/mh.c
@@ -581,7 +581,7 @@ int mh_check_mailbox(CONTEXT *ctx, int *index_hint)
struct maildir *md, *p;
struct maildir **last;
HASH *fnames;
- int i, j;
+ int i, idx;
if(!option (OPTCHECKNEW))
return 0;
@@ -659,23 +659,23 @@ int mh_check_mailbox(CONTEXT *ctx, int *index_hint)
hash_insert(fnames, p->canon_fname, p, 0);
}
+
+ if(index_hint) idx = *index_hint;
for(i = 0; i < ctx->msgcount; i++)
{
ctx->hdrs[i]->active = 0;
+
if(ctx->magic == M_MAILDIR)
maildir_canon_filename(b1, ctx->hdrs[i]->path, sizeof(b1));
else
strfcpy(b1, ctx->hdrs[i]->path, sizeof(b1));
- if((p = hash_find(fnames, b1)))
+ if((p = hash_find(fnames, b1)) && p->h &&
+ mbox_strict_cmp_headers(ctx->hdrs[i], p->h))
{
- if(!p->h)
- continue;
-
- if(!mbox_strict_cmp_headers(ctx->hdrs[i], p->h))
- continue;
-
+ /* found the right message */
+
if(modified)
{
if(!ctx->hdrs[i]->changed)
@@ -690,6 +690,15 @@ int mh_check_mailbox(CONTEXT *ctx, int *index_hint)
ctx->hdrs[i]->active = 1;
mutt_free_header(&p->h);
}
+ else
+ {
+ /* the message has disappeared by occult forces, correct
+ * the index hint.
+ */
+
+ if(index_hint && (i <= *index_hint))
+ idx--;
+ }
}
hash_destroy(&fnames, NULL);
@@ -698,6 +707,10 @@ int mh_check_mailbox(CONTEXT *ctx, int *index_hint)
mx_update_tables(ctx, 0);
maildir_move_to_context(ctx, &md);
+
+ if(index_hint)
+ *index_hint = idx;
+
return modified ? M_REOPENED : have_new ? M_NEW_MAIL : 0;
}