Mercurial > dovecot > core-2.2
changeset 1008:b5ca53885d07 HEAD
Some fixes for handling messageset ranges.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 21 Jan 2003 22:06:49 +0200 |
parents | 1222ab408f63 |
children | fb83ce2a26c3 |
files | src/lib-storage/index/index-messageset.c |
diffstat | 1 files changed, 22 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/index-messageset.c Tue Jan 21 21:56:33 2003 +0200 +++ b/src/lib-storage/index/index-messageset.c Tue Jan 21 22:06:49 2003 +0200 @@ -56,8 +56,13 @@ struct messageset_context *ctx; ctx = index_messageset_init(ibox, NULL, uidset); - ctx->num1 = num1; - ctx->num2 = num2; + if (num1 <= num2) { + ctx->num1 = num1; + ctx->num2 = num2; + } else { + ctx->num1 = num2; + ctx->num2 = num1; + } return ctx; } @@ -168,9 +173,17 @@ ctx->num1 = rec == NULL ? 0 : rec->uid; } - if (ctx->num2 == (unsigned int)-1) + if (ctx->num2 == (unsigned int)-1) { ctx->num2 = ctx->index->header->next_uid-1; + /* num1 might actually be larger, check */ + if (ctx->num1 > ctx->num2) { + unsigned int temp = ctx->num1; + ctx->num1 = ctx->num2; + ctx->num2 = temp; + } + } + /* get list of expunged messages in our range. */ ctx->expunges = mail_modifylog_uid_get_expunges(ctx->index->modifylog, ctx->num1, ctx->num2, @@ -247,6 +260,12 @@ mail->rec = ctx->index->next(ctx->index, mail->rec); mail->client_seq++; mail->idx_seq++; + + if (mail->rec == NULL) { + /* finished early (high UID larger than exists) */ + ctx->ret = 1; + return NULL; + } } else { do { if (ctx->p != NULL && *ctx->p == '\0') {