dovecot: mail_index_lookup_uid_range() works now correctly when ...
dovecot at dovecot.org
dovecot at dovecot.org
Mon Jul 16 09:48:07 EEST 2007
details: http://hg.dovecot.org/dovecot/rev/5d3a941444f1
changeset: 6036:5d3a941444f1
user: Timo Sirainen <tss at iki.fi>
date: Mon Jul 16 07:52:50 2007 +0300
description:
mail_index_lookup_uid_range() works now correctly when searching for newly
appended messages.
diffstat:
1 file changed, 30 insertions(+), 10 deletions(-)
src/lib-index/mail-index-transaction-view.c | 40 ++++++++++++++++++++-------
diffs (55 lines):
diff -r b6fe8568f207 -r 5d3a941444f1 src/lib-index/mail-index-transaction-view.c
--- a/src/lib-index/mail-index-transaction-view.c Mon Jul 16 03:22:26 2007 +0300
+++ b/src/lib-index/mail-index-transaction-view.c Mon Jul 16 07:52:50 2007 +0300
@@ -109,21 +109,41 @@ static int _tview_lookup_uid_range(struc
{
struct mail_index_view_transaction *tview =
(struct mail_index_view_transaction *)view;
+ const struct mail_index_record *rec;
+ uint32_t seq;
if (tview->super->lookup_uid_range(view, first_uid, last_uid,
first_seq_r, last_seq_r) < 0)
return -1;
- /* FIXME: we don't need this function yet.. new UIDs might be 0 as
- well.. */
-
- if (*first_seq_r == 0) {
- /* nothing found, either doesn't exist or it's completely
- newly appended. */
- } else if (*last_seq_r + 1 == tview->t->first_new_seq) {
- /* last_seq_r may be growed from transactions */
- }
-
+ if (tview->t->last_new_seq == 0) {
+ /* no new messages, the results are final. */
+ return 0;
+ }
+
+ rec = mail_index_transaction_lookup(tview->t, tview->t->first_new_seq);
+ if (rec->uid == 0) {
+ /* new messages don't have UIDs */
+ return 0;
+ }
+ if (last_uid < rec->uid) {
+ /* all wanted messages were existing */
+ return 0;
+ }
+
+ /* at least some of the wanted messages are newly created */
+ if (*first_seq_r == 0)
+ *first_seq_r = tview->t->first_new_seq;
+
+ seq = tview->t->last_new_seq;
+ for (; seq >= tview->t->first_new_seq; seq--) {
+ rec = mail_index_transaction_lookup(tview->t, seq);
+ if (rec->uid <= last_uid) {
+ *last_seq_r = seq;
+ break;
+ }
+ }
+ i_assert(seq >= tview->t->first_new_seq);
return 0;
}
More information about the dovecot-cvs
mailing list