summaryrefslogtreecommitdiffstats
path: root/mh.c
diff options
context:
space:
mode:
authorThomas Roessler <roessler@does-not-exist.org>1999-05-06 08:29:17 +0000
committerThomas Roessler <roessler@does-not-exist.org>1999-05-06 08:29:17 +0000
commit7ce926170cda0b4efc581c8323edcc9f04b36aa1 (patch)
treeda94f57f22052444b43c6e8b0bfcbad26b77dc24 /mh.c
parente64942a90a603d379215be3d974936118cac515c (diff)
Fixing more maildir cursor problems.
Diffstat (limited to 'mh.c')
-rw-r--r--mh.c50
1 files changed, 41 insertions, 9 deletions
diff --git a/mh.c b/mh.c
index 15beddba..5b398b50 100644
--- a/mh.c
+++ b/mh.c
@@ -530,7 +530,7 @@ static int maildir_sync_message (CONTEXT *ctx, int msgno)
int mh_sync_mailbox (CONTEXT * ctx)
{
char path[_POSIX_PATH_MAX], tmp[_POSIX_PATH_MAX];
- int i, rc = 0;
+ int i, j, rc = 0;
i = mh_check_mailbox(ctx, NULL);
@@ -569,12 +569,27 @@ int mh_sync_mailbox (CONTEXT * ctx)
maildir_sync_message (ctx, i);
else
{
- /* FOO - seems ok to ignore errors, but might want to warn... */
+ /* XXX - seems ok to ignore errors, but might want to warn... */
mh_sync_message (ctx, i);
}
}
}
+
+ /* XXX race condition? */
+
maildir_update_mtime(ctx);
+
+ /* adjust indices */
+
+ if (ctx->deleted)
+ {
+ for (i = 0, j = 0; i < ctx->msgcount; i++)
+ {
+ if (!ctx->hdrs[i]->deleted)
+ ctx->hdrs[i]->index = j++;
+ }
+ }
+
return (rc);
}
@@ -612,7 +627,7 @@ int mh_check_mailbox(CONTEXT *ctx, int *index_hint)
struct maildir *md, *p;
struct maildir **last;
HASH *fnames;
- int i, deleted;
+ int i, j, deleted;
if(!option (OPTCHECKNEW))
return 0;
@@ -777,22 +792,39 @@ int mh_check_mailbox(CONTEXT *ctx, int *index_hint)
occult = 1;
- if(index_hint && (i < *index_hint))
- deleted++;
}
}
- if (index_hint && occult)
- *index_hint -= deleted;
-
- /* dump the file name hash */
+ /* destroy the file name hash */
hash_destroy(&fnames, NULL);
/* If we didn't just get new mail, update the tables. */
if(modified || occult)
+ {
+ short old_sort;
+ int old_count;
+
+ if (Sort != SORT_ORDER)
+ {
+ old_sort = Sort;
+ Sort = SORT_ORDER;
+ mutt_sort_headers (ctx, 1);
+ Sort = old_sort;
+ }
+
+ old_count = ctx->msgcount;
+ for (i = 0, j = 0; i < old_count; i++)
+ {
+ if (ctx->hdrs[i]->active && index_hint && *index_hint == i)
+ *index_hint = j;
+
+ if (ctx->hdrs[i]->active)
+ ctx->hdrs[i]->index = j++;
+ }
mx_update_tables(ctx, 0);
+ }
/* Incorporate new messages */