time_t received_date, save_date;
int received_tz_offset;
- uint32_t uid;
+ uint32_t uid, stub_seq;
char *guid, *pop3_uidl, *from_envelope;
unsigned int pop3_order;
{
struct mailbox_transaction_context *trans;
+ i_assert((flags & MAILBOX_TRANSACTION_FLAG_FILL_IN_STUB) == 0 ||
+ (box->flags & MAILBOX_FLAG_USE_STUBS) != 0);
+
i_assert(box->opened);
box->transaction_count++;
void mailbox_save_set_uid(struct mail_save_context *ctx, uint32_t uid)
{
ctx->data.uid = uid;
+ if ((ctx->transaction->flags & MAILBOX_TRANSACTION_FLAG_FILL_IN_STUB) != 0) {
+ if (!mail_index_lookup_seq(ctx->transaction->view, uid,
+ &ctx->data.stub_seq) < 0)
+ i_panic("Trying to fill in stub for nonexistent UID %u", uid);
+ }
}
void mailbox_save_set_guid(struct mail_save_context *ctx, const char *guid)
return -1;
}
+ /* if we're filling in a stub, we must have set UID already
+ (which in turn sets stub_seq) */
+ i_assert(((*ctx)->transaction->flags & MAILBOX_TRANSACTION_FLAG_FILL_IN_STUB) == 0 ||
+ (*ctx)->data.stub_seq != 0);
+
if (!(*ctx)->copying_or_moving) {
/* We're actually saving the mail. We're not being called by
mail_storage_copy() because backend didn't support fast
inconsistent. For example this disables lazy_expunge plugin and
quota updates (possibly resulting in broken quota). and This is
useful for example when deleting entire user accounts. */
- MAILBOX_FLAG_DELETE_UNSAFE = 0x400
+ MAILBOX_FLAG_DELETE_UNSAFE = 0x400,
+ /* Mailbox is used for caching purposes. Some of the mails may be
+ stubs, which exist in the index but that don't have a mail body.
+ The backend shouldn't treat it as corruption if a mail body isn't
+ found. */
+ MAILBOX_FLAG_USE_STUBS = 0x800,
};
enum mailbox_feature {
/* Don't trigger any notifications for this transaction. This
especially means the notify plugin. This would normally be used only
with _FLAG_SYNC. */
- MAILBOX_TRANSACTION_FLAG_NO_NOTIFY = 0x40
+ MAILBOX_TRANSACTION_FLAG_NO_NOTIFY = 0x40,
+ /* Append fills in an existing stub mail for the specified UID,
+ instead of saving a new mail. This requires mailbox to be opened
+ with MAILBOX_FLAG_USE_STUBS. */
+ MAILBOX_TRANSACTION_FLAG_FILL_IN_STUB = 0x80,
};
enum mailbox_sync_flags {