/* Copyright (c) 2002-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "seq-range-array.h"
#include "ioloop.h"
#include "array.h"
#include "index-mailbox-size.h"
#include "index-sync-private.h"
#include "mailbox-recent-flags.h"
struct index_storage_list_index_record {
};
{
}
return sync_flags;
}
enum mailbox_sync_flags flags)
{
if ((flags & MAILBOX_SYNC_FLAG_FAST) != 0 &&
return FALSE;
if ((flags & MAILBOX_SYNC_FLAG_FAST) != 0 &&
/* lib-lda is syncing the mailbox after saving a mail.
it only wants to find the new mail for potentially copying
to other mailboxes. that's mainly an optimization, and since
the mail was most likely already added to index we don't
need to do a full sync to find it. the main benefit here is
return FALSE;
}
return TRUE;
}
{
break;
} else {
}
break;
}
}
}
static void
{
/* remove expunged messages from flag updates */
}
/* remove flag updates from hidden updates */
&ctx->flag_updates);
}
struct mailbox_sync_context *
bool failed)
{
if (failed) {
}
if ((flags & MAILBOX_SYNC_FLAG_NO_EXPUNGES) != 0)
if ((flags & MAILBOX_SYNC_FLAG_FIX_INCONSISTENT) != 0) {
ctx->messages_count = 0;
} else {
}
if ((flags & MAILBOX_SYNC_FLAG_FAST) != 0) {
/* we most likely did a fast sync. refresh the index anyway in
case there were some new changes. */
}
if ((flags & MAILBOX_SYNC_FLAG_NO_EXPUNGES) == 0) {
}
/* sync private index if needed. it doesn't use box->view, so it
doesn't matter if it's called at _sync_init() or _sync_deinit().
however we also need to know if any private flags have changed
since last sync, so we need to call it before _sync_next() calls. */
&ctx->hidden_updates);
}
}
static bool
struct mailbox_sync_rec *sync_rec_r)
{
if (ctx->expunge_pos == 0)
return FALSE;
/* expunges is a sorted array of sequences. it's easiest for
us to print them from end to beginning. */
ctx->expunge_pos--;
return TRUE;
}
struct mailbox_sync_rec *sync_rec_r)
{
(struct index_mailbox_sync_context *)_ctx;
unsigned int count;
return FALSE;
ctx->flag_update_idx++;
return TRUE;
}
/* hidden flag changes' MODSEQs still need to be returned */
ctx->hidden_update_idx++;
return TRUE;
}
}
}
static void
{
return;
/* expunges array contained expunges for the messages that were already
visible in this view, but append+expunge would be invisible.
recent_flags may however contain the append UID, so we'll have to
remove it separately */
if (ctx->messages_count == 0)
uid = 0;
else {
return;
}
continue;
}
uid + 1,
}
#ifdef DEBUG
if (!mail_index_view_is_inconsistent(view)) {
unsigned int i, count;
for (i = 0; i < count; i++) {
break;
}
}
}
#endif
}
{
"first_recent_uid unexpectedly shrank: %u -> %u",
}
}
}
}
{
}
struct mailbox_sync_status *status_r)
{
(struct index_mailbox_sync_context *)_ctx;
/* finish handling expunges, so we don't break when updating
recent flags */
/* convert sequences to uids before syncing view */
&delayed_expunges) < 0) {
ret = -1;
}
}
if (ret < 0) {
return -1;
}
/* mailbox syncing didn't necessarily update our recent state */
}
/* update search results after private index is updated */
/* update vsize header if wanted */
/* we probably had MAILBOX_SYNC_FLAG_FIX_INCONSISTENT set,
but the view got broken in the middle. FIXME: We could
attempt to fix it automatically. In any case now the view
isn't usable and we can't return success. */
ret = -1;
}
return ret;
}
{
if (!array_is_created(k1))
if (!array_is_created(k2))
return array_count(k1) == 0;
/* The arrays may not be sorted, but they usually are. Optimize for
the assumption that they are */
return FALSE;
for (i = 0; i < count1; i++) {
/* not found / unsorted array. check. */
for (j = 0; j < count1; j++) {
break;
}
if (j == count1)
return FALSE;
}
}
return TRUE;
}
{
if ((type & MAIL_INDEX_SYNC_TYPE_EXPUNGE) != 0)
if ((type & (MAIL_INDEX_SYNC_TYPE_FLAGS |
return ret;
}
static uint32_t
{
"index sync", 0,
sizeof(struct index_storage_list_index_record),
sizeof(uint32_t));
}
return ibox->list_index_sync_ext_id;
}
struct mail_index_view *list_view,
{
const void *data;
bool expunged;
int ret;
/* doesn't exist / not synced */
}
return INDEX_STORAGE_LIST_CHANGE_NONE;
if (ret < 0)
return INDEX_STORAGE_LIST_CHANGE_ERROR;
return INDEX_STORAGE_LIST_CHANGE_ERROR;
}
return INDEX_STORAGE_LIST_CHANGE_NONE;
}
struct mail_index_view *list_view,
{
return -1;
return 0;
default:
return 1;
}
}
struct mail_index_transaction *trans,
{
const void *data;
bool expunged;
int ret;
return;
/* get the current record */
if (expunged)
return;
if (ret < 0)
return;
return;
}
}