/* Copyright (c) 2002-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "seq-range-array.h"
#include "mail-search.h"
#include "mailbox-search-result-private.h"
#include "index-storage.h"
#include "index-search-result.h"
static void
unsigned int *idx,
{
unsigned int i, count;
/* remove full seq_ranges */
i++;
}
/* remove the last seq_range */
/* finished this range */
if (++i < count)
else {
/* this was the last searched message */
uid = 0;
}
}
*idx = i;
}
static int
{
struct mailbox_transaction_context *t;
int ret;
i_assert(changed_count > 0);
changed_idx = 0;
/* tell search that we're updating an existing search result,
so it can do some optimizations based on it */
/* some messages in changed_uids didn't match.
make sure they don't exist in the search result. */
&changed_idx, &next_uid,
}
next_uid++;
} else if (++changed_idx < changed_count) {
} else {
/* this was the last searched message */
next_uid = 0;
}
/* match - make sure it exists in search result */
}
/* last message(s) didn't match. make sure they don't exist
in the search result. */
&changed_idx, &next_uid,
}
if (mailbox_transaction_commit(&t) < 0)
ret = -1;
return ret;
}
{
int ret;
if (array_count(uids) == 0)
return 0;
/* add a temporary search parameter to limit the search only to
the changed messages */
i_zero(&search_arg);
return ret;
}
unsigned int old_messages_count)
{
struct mailbox_transaction_context *t;
int ret;
if (old_messages_count == message_count) {
/* no new messages */
return 0;
}
/* add a temporary search parameter to limit the search only to
the new messages */
i_zero(&search_arg);
/* add all messages matching the search to search result */
if (mailbox_transaction_commit(&t) < 0)
ret = -1;
return ret;
}
{
return;
}
}
}