diff options
author | Thomas Roessler <roessler@does-not-exist.org> | 1999-09-11 13:49:37 +0000 |
---|---|---|
committer | Thomas Roessler <roessler@does-not-exist.org> | 1999-09-11 13:49:37 +0000 |
commit | 4104e5ad2a6f445c582774e6a6fdd41e0201d7e2 (patch) | |
tree | 592dbd1b36dda45fd42f365ccd0fc91d6412e1fc /imap | |
parent | f24c25bff3454897fbb8a6a888d1311e867f800e (diff) |
Fix IMAP fast deletion. From Brendan.
Diffstat (limited to 'imap')
-rw-r--r-- | imap/browse.c | 2 | ||||
-rw-r--r-- | imap/imap.c | 27 |
2 files changed, 22 insertions, 7 deletions
diff --git a/imap/browse.c b/imap/browse.c index 4567767c..7c403136 100644 --- a/imap/browse.c +++ b/imap/browse.c @@ -162,7 +162,7 @@ int imap_init_browse (char *path, struct browser_state *state) * folder + delimiter. Cyrus servers don't. So we ask for folder, * and tack on delimiter ourselves. */ for (n--; n >= 0 && mbox[n] != idata->delim ; n--); - if (n > 0) /* "aaaa/bbbb/" -> "aaaa/" */ + if (n > 0) /* "aaaa/bbbb/" -> "aaaa" */ { ctmp = mbox[n]; mbox[n] = '\0'; diff --git a/imap/imap.c b/imap/imap.c index c1540451..e66e5ff2 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -1285,7 +1285,6 @@ int imap_sync_mailbox (CONTEXT *ctx, int expunge) char flags[LONG_STRING]; char tmp[LONG_STRING]; int n; - int setstart = 0; if (CTX_DATA->state != IMAP_SELECTED) { @@ -1296,10 +1295,20 @@ int imap_sync_mailbox (CONTEXT *ctx, int expunge) /* if we are expunging anyway, we can do deleted messages very quickly... */ if (expunge && mutt_bit_isset (CTX_DATA->rights, IMAP_ACL_DELETE)) { + int setstart = 0; + HEADER** hdrs; + buf[0] = '\0'; + + /* make copy of header pointers to sort in natural order */ + hdrs = safe_calloc (ctx->msgcount, sizeof (HEADER*)); + memcpy (hdrs, ctx->hdrs, ctx->msgcount * sizeof (HEADER*)); + qsort ((void*) hdrs, ctx->msgcount, sizeof (HEADER*), + mutt_get_sort_func (SORT_ORDER)); + for (n = 0; n < ctx->msgcount; n++) { - if (ctx->hdrs[n]->changed && ctx->hdrs[n]->deleted) + if (hdrs[n]->changed && hdrs[n]->deleted) { if (setstart == 0) { @@ -1319,15 +1328,21 @@ int imap_sync_mailbox (CONTEXT *ctx, int expunge) snprintf (buf, sizeof (buf), "%s:%u", tmp, n+1); } /* the normal flag update can skip this message */ - ctx->hdrs[n]->changed = 0; + hdrs[n]->changed = 0; } - else if (setstart && (n > setstart)) + else if (setstart) { + if (n > setstart) + { + strncpy (tmp, buf, sizeof (tmp)); + snprintf (buf, sizeof (buf), "%s:%u", tmp, n); + } setstart = 0; - strncpy (tmp, buf, sizeof (tmp)); - snprintf (buf, sizeof (buf), "%s:%u", tmp, n); } } + + safe_free ((void**) &hdrs); + /* if we have a message set, then let's delete */ if (buf[0]) { |