int mbox_file_open_stream(struct mbox_mailbox *mbox) { if (mbox->mbox_stream != NULL) return 0; if (mbox->mbox_file_stream != NULL) { /* read-only mbox stream */ i_assert(mbox->mbox_fd == -1 && mbox_is_backend_readonly(mbox)); } else { if (mbox->mbox_fd == -1) { if (mbox_file_open(mbox) < 0) return -1; } if (mbox->mbox_writeonly) { mbox->mbox_file_stream = i_stream_create_from_data("", 0); } else { mbox->mbox_file_stream = i_stream_create_fd(mbox->mbox_fd, MBOX_READ_BLOCK_SIZE); i_stream_set_init_buffer_size(mbox->mbox_file_stream, MBOX_READ_BLOCK_SIZE); } i_stream_set_name(mbox->mbox_file_stream, mailbox_get_path(&mbox->box)); } mbox->mbox_stream = i_stream_create_raw_mbox(mbox->mbox_file_stream); if (mbox->mbox_lock_type != F_UNLCK) istream_raw_mbox_set_locked(mbox->mbox_stream); return 0; }
void index_mail_set_read_buffer_size(struct mail *_mail, struct istream *input) { struct index_mail *mail = (struct index_mail *)_mail; unsigned int block_size; i_stream_set_max_buffer_size(input, MAIL_READ_FULL_BLOCK_SIZE); block_size = (index_mail_get_access_part(mail) & READ_BODY) != 0 ? MAIL_READ_FULL_BLOCK_SIZE : MAIL_READ_HDR_BLOCK_SIZE; i_stream_set_init_buffer_size(input, block_size); }