/* updated for each appended mail: */
uint32_t seq;
struct istream *input;
- struct mail *mail;
int fd;
bool failed:1;
_ctx->data.min_modseq);
}
- if (_ctx->dest_mail == NULL) {
- if (ctx->mail == NULL)
- ctx->mail = mail_alloc(trans, 0, NULL);
- _ctx->dest_mail = ctx->mail;
- }
mail_set_seq_saving(_ctx->dest_mail, ctx->seq);
crlf_input = i_stream_create_crlf(input);
return -1;
}
}
-
- if (ctx->mail != NULL)
- mail_free(&ctx->mail);
return 0;
}
if (ctx->sync_ctx != NULL)
(void)cydir_sync_finish(&ctx->sync_ctx, FALSE);
- if (ctx->mail != NULL)
- mail_free(&ctx->mail);
i_free(ctx->tmp_basename);
i_free(ctx);
}
dbox_save_add_to_index(ctx);
- if (_ctx->dest_mail == NULL) {
- if (ctx->mail == NULL)
- ctx->mail = mail_alloc(_ctx->transaction, 0, NULL);
- _ctx->dest_mail = ctx->mail;
- }
mail_set_seq_saving(_ctx->dest_mail, ctx->seq);
crlf_input = i_stream_create_lf(input);
/* updated for each appended mail: */
uint32_t seq;
struct istream *input;
- struct mail *mail;
struct ostream *dbox_output;
mail_index_sync_set_reason(ctx->sync_ctx->index_sync_ctx, "saving");
}
- if (ctx->ctx.mail != NULL)
- mail_free(&ctx->ctx.mail);
-
_t->changes->uid_validity = hdr->uid_validity;
return 0;
}
if (ctx->sync_ctx != NULL)
(void)mdbox_sync_finish(&ctx->sync_ctx, FALSE);
- if (ctx->ctx.mail != NULL)
- mail_free(&ctx->ctx.mail);
array_free(&ctx->mails);
i_free(ctx);
}
save_mail = array_append_space(&ctx->mails);
save_mail->seq = ctx->ctx.seq;
- if (_ctx->dest_mail != NULL)
- mail_set_seq_saving(_ctx->dest_mail, ctx->ctx.seq);
+ mail_set_seq_saving(_ctx->dest_mail, ctx->ctx.seq);
index_save_context_free(_ctx);
return 0;
}
index_copy_cache_fields(_ctx, mail, ctx->seq);
sdbox_save_add_file(_ctx, dest_file);
- if (_ctx->dest_mail != NULL)
- mail_set_seq_saving(_ctx->dest_mail, ctx->seq);
+ mail_set_seq_saving(_ctx->dest_mail, ctx->seq);
dbox_file_unref(&src_file);
return 1;
}
if (array_count(&ctx->files) == 0) {
/* the mail must be freed in the commit_pre() */
- if (ctx->ctx.mail != NULL)
- mail_free(&ctx->ctx.mail);
return 0;
}
}
}
- if (ctx->ctx.mail != NULL)
- mail_free(&ctx->ctx.mail);
-
_t->changes->uid_validity = hdr->uid_validity;
return 0;
}
if (ctx->sync_ctx != NULL)
(void)sdbox_sync_finish(&ctx->sync_ctx, FALSE);
-
- if (ctx->ctx.mail != NULL)
- mail_free(&ctx->ctx.mail);
i_free(ctx);
}
struct index_mail *imail = (struct index_mail *)_mail;
uint32_t seq;
- if (_mail == NULL)
- return;
-
/* we'll temporarily append messages and at commit time expunge
them all, since we can't guarantee that no one else has saved
messages to remote server during our transaction */
{
struct index_mail *imail = (struct index_mail *)ctx->dest_mail;
- if (imail == NULL)
- return;
-
if (ctx->data.from_envelope != NULL &&
imail->data.from_envelope == NULL) {
imail->data.from_envelope =
if (mail_cache_lookup_field(src_mail->transaction->cache_view, buf,
src_mail->seq, src_field_idx) <= 0)
buffer_set_used_size(buf, 0);
- else if (ctx->dest_mail != NULL &&
- (strcmp(name, "size.physical") == 0 ||
- strcmp(name, "size.virtual") == 0)) {
+ else if (strcmp(name, "size.physical") == 0 ||
+ strcmp(name, "size.virtual") == 0) {
/* FIXME: until mail_cache_lookup() can read unwritten
cached data from buffer, we'll do this optimization
to make quota plugin's work faster */
struct maildir_uidlist_sync_ctx *uidlist_sync_ctx;
struct maildir_keywords_sync_ctx *keywords_sync_ctx;
struct maildir_index_sync_context *sync_ctx;
- struct mail *mail, *cur_dest_mail;
+ struct mail *cur_dest_mail;
const char *tmpdir, *newdir, *curdir;
struct maildir_filename *files, **files_tail, *file_last;
i_assert(ctx->files->next == NULL);
}
- if (_ctx->dest_mail == NULL) {
- if (ctx->mail == NULL)
- ctx->mail = mail_alloc(_ctx->transaction, 0, NULL);
- _ctx->dest_mail = ctx->mail;
- }
mail_set_seq_saving(_ctx->dest_mail, ctx->seq);
if (ctx->input == NULL) {
i_assert(_ctx->data.output == NULL);
i_assert(ctx->last_save_finished);
- if (ctx->files_count == 0) {
- /* the mail must be freed in the commit_pre() */
- if (ctx->mail != NULL)
- mail_free(&ctx->mail);
+ if (ctx->files_count == 0)
return 0;
- }
sync_flags = MAILDIR_UIDLIST_SYNC_PARTIAL |
MAILDIR_UIDLIST_SYNC_NOREFRESH;
_t->changes->uid_validity =
maildir_uidlist_get_uid_validity(ctx->mbox->uidlist);
- if (ctx->mail != NULL) {
- /* Mail freeing may trigger cache updates and a call to
- maildir_save_file_get_path(). Do this before finishing index
- sync so we still have keywords_sync_ctx. */
- mail_free(&ctx->mail);
- }
-
if (ctx->locked) {
/* It doesn't matter if index syncing fails */
ctx->keywords_sync_ctx = NULL;
if (ctx->locked)
maildir_uidlist_unlock(ctx->mbox->uidlist);
- if (ctx->mail != NULL)
- mail_free(&ctx->mail);
pool_unref(&ctx->pool);
}
struct mbox_mailbox *mbox;
struct mail_index_transaction *trans;
- struct mail *mail;
uoff_t append_offset, mail_offset;
time_t orig_atime;
static int
mbox_save_init_file(struct mbox_save_context *ctx,
- struct mbox_transaction_context *t, bool want_mail)
+ struct mbox_transaction_context *t)
{
struct mailbox_transaction_context *_t = &t->t;
struct mbox_mailbox *mbox = ctx->mbox;
struct mail_storage *storage = &mbox->storage->storage;
- bool empty = FALSE;
int ret;
if (mbox_is_backend_readonly(ctx->mbox)) {
return -1;
}
- if ((_t->flags & MAILBOX_TRANSACTION_FLAG_ASSIGN_UIDS) != 0 ||
- ctx->ctx.data.uid != 0)
- want_mail = TRUE;
-
if (ctx->append_offset == (uoff_t)-1) {
/* first appended mail in this transaction */
if (t->write_lock_id == 0) {
}
/* update mbox_sync_dirty state */
- ret = mbox_sync_has_changed_full(mbox, TRUE, &empty);
+ ret = mbox_sync_has_changed(mbox, TRUE);
if (ret < 0)
return -1;
- if (!want_mail && ret == 0) {
- /* we're not required to assign UIDs for the appended
- mails immediately. do it only if it doesn't require
- syncing. */
- mbox_save_init_sync(_t);
- }
}
- if (!ctx->synced && (want_mail || empty)) {
+ if (!ctx->synced) {
/* we'll need to assign UID for the mail immediately. */
if (mbox_sync(mbox, 0) < 0)
return -1;
i_stream_create_crlf(filter) : i_stream_create_lf(filter);
i_stream_unref(&filter);
- if (ctx->ctx.dest_mail != NULL) {
- /* caching creates a tee stream */
- cache_input =
- index_mail_cache_parse_init(ctx->ctx.dest_mail, ret);
- i_stream_unref(&ret);
- ret = cache_input;
- }
+ /* caching creates a tee stream */
+ cache_input = index_mail_cache_parse_init(ctx->ctx.dest_mail, ret);
+ i_stream_unref(&ret);
+ ret = cache_input;
return ret;
}
ctx->failed = FALSE;
ctx->seq = 0;
- if (mbox_save_init_file(ctx, t, _ctx->dest_mail != NULL) < 0) {
+ if (mbox_save_init_file(ctx, t) < 0) {
ctx->failed = TRUE;
return -1;
}
ctx->next_uid++;
/* parse and cache the mail headers as we read it */
- if (_ctx->dest_mail == NULL) {
- if (ctx->mail == NULL) {
- ctx->mail = mail_alloc(_ctx->transaction,
- 0, NULL);
- }
- _ctx->dest_mail = ctx->mail;
- }
mail_set_seq_saving(_ctx->dest_mail, ctx->seq);
}
mbox_save_append_flag_headers(ctx->headers, save_flags);
while ((ret = i_stream_read(ctx->input)) != -1) {
if (mbox_save_body_input(ctx) < 0)
return -1;
- if (ctx->ctx.dest_mail != NULL) {
- /* i_stream_read() may have returned 0 at EOF
- because of this parser */
- index_mail_cache_parse_continue(ctx->ctx.dest_mail);
- }
+ /* i_stream_read() may have returned 0 at EOF
+ because of this parser */
+ index_mail_cache_parse_continue(ctx->ctx.dest_mail);
if (ret == 0)
return 0;
}
i_assert(size > 0);
ctx->last_char = data[size-1];
i_stream_skip(ctx->input, size);
- if (ctx->ctx.dest_mail != NULL)
- index_mail_cache_parse_continue(ctx->ctx.dest_mail);
+ index_mail_cache_parse_continue(ctx->ctx.dest_mail);
}
if (ret == 0)
return 0;
} T_END;
}
- if (ctx->ctx.dest_mail != NULL) {
- index_mail_cache_parse_deinit(ctx->ctx.dest_mail,
- ctx->ctx.data.received_date,
- !ctx->failed);
- }
+ index_mail_cache_parse_deinit(ctx->ctx.dest_mail,
+ ctx->ctx.data.received_date,
+ !ctx->failed);
if (ctx->input != NULL)
i_stream_destroy(&ctx->input);
{
if (ctx->output != NULL)
o_stream_destroy(&ctx->output);
- if (ctx->mail != NULL)
- mail_free(&ctx->mail);
str_free(&ctx->headers);
}
int mbox_sync_header_refresh(struct mbox_mailbox *mbox);
int mbox_sync(struct mbox_mailbox *mbox, enum mbox_sync_flags flags);
int mbox_sync_has_changed(struct mbox_mailbox *mbox, bool leave_dirty);
-int mbox_sync_has_changed_full(struct mbox_mailbox *mbox, bool leave_dirty,
- bool *empty_r);
void mbox_sync_set_critical(struct mbox_sync_context *sync_ctx,
const char *fmt, ...) ATTR_FORMAT(2, 3);
}
int mbox_sync_has_changed(struct mbox_mailbox *mbox, bool leave_dirty)
-{
- bool empty;
-
- return mbox_sync_has_changed_full(mbox, leave_dirty, &empty);
-}
-
-int mbox_sync_has_changed_full(struct mbox_mailbox *mbox, bool leave_dirty,
- bool *empty_r)
{
const struct stat *st;
struct stat statbuf;
}
st = &statbuf;
}
- *empty_r = st->st_size == 0;
if (mbox_sync_header_refresh(mbox) < 0)
return -1;