mail-index-transaction.c revision 3b426f49d36187895debdda67fff09f97941881c
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainen/* Copyright (c) 2003-2010 Dovecot authors, see the included COPYING file */
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainenmail_index_transaction_get_view(struct mail_index_transaction *t)
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainenbool mail_index_transaction_is_expunged(struct mail_index_transaction *t,
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainenvoid mail_index_transaction_ref(struct mail_index_transaction *t)
859cc94211b759825db5e15b0c88754da902ca14Timo Sirainenvoid mail_index_transaction_unref(struct mail_index_transaction **_t)
9e095dd6a77097356aca8216356d4d71ef1bea45Timo Sirainenuint32_t mail_index_transaction_get_next_uid(struct mail_index_transaction *t)
9b1d6da0f2b42b8b6f612a570a83355c2a5088eeTimo Sirainen const struct mail_index_header *head_hdr, *hdr;
9b1d6da0f2b42b8b6f612a570a83355c2a5088eeTimo Sirainen unsigned int offset;
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainen next_uid = t->reset || head_hdr->uid_validity != hdr->uid_validity ?
1117aa7adc2909c750031fd7551a58a486d100d8Timo Sirainen if (array_is_created(&t->appends) && t->highest_append_uid != 0) {
e50c7afe297ab10e07a8acc816c76ce9d45ef409Timo Sirainen /* get next_uid from appends if they have UIDs. it's possible
1117aa7adc2909c750031fd7551a58a486d100d8Timo Sirainen that some appends have too low UIDs, they'll be caught
9b1d6da0f2b42b8b6f612a570a83355c2a5088eeTimo Sirainen /* see if it's been updated in pre/post header changes */
601f5f14c6cde28f0e0c6ca7c5d735315d3d48dfTimo Sirainen offset = offsetof(struct mail_index_header, next_uid);
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainenmail_transaction_log_file_refresh(struct mail_index_transaction *t,
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainen /* Reset the whole index, preserving only indexid. Begin by
7d207b1e77a7b5e3fda640e353acfc86d261fedfTimo Sirainen rotating the log. We don't care if we skip some non-synced
07e4875d250e7a7157cd99132aafc773cf3cdf83Timo Sirainen transactions. */
07e4875d250e7a7157cd99132aafc773cf3cdf83Timo Sirainen if (mail_transaction_log_rotate(t->view->index->log, TRUE) < 0)
07e4875d250e7a7157cd99132aafc773cf3cdf83Timo Sirainen /* we only wanted to reset */
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainen /* update sync_offset */
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainen if (mail_transaction_log_file_map(file, file->sync_offset,
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainen i_assert(file->sync_offset >= file->buffer_offset);
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainen ctx->new_highest_modseq = file->sync_highest_modseq;
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainenmail_index_transaction_commit_real(struct mail_index_transaction *t,
a94936bafd127680184da114c6a177b37ff656e5Timo Sirainen struct mail_transaction_log *log = t->view->index->log;
a94936bafd127680184da114c6a177b37ff656e5Timo Sirainen bool external = (t->flags & MAIL_INDEX_TRANSACTION_FLAG_EXTERNAL) != 0;
dd62b77c932d1b518f2a3e4bf80e36542becc256Timo Sirainen if (mail_transaction_log_append_begin(log->index, external, &ctx) < 0)
411d6baa37f31d90730e90c4a28c43e1974bbe58Timo Sirainen ret = mail_transaction_log_file_refresh(t, ctx);
if (t->reset) {
bool changed;
int ret;
return ret;
if (!index_undeleted) {
if (index_undeleted) {
t->v.rollback(t);
struct mail_index_transaction *
struct mail_index_transaction *t;
t->v = trans_vfuncs;
t->first_new_seq =