From: Josef 'Jeff' Sipek Date: Wed, 11 Mar 2020 12:33:51 +0000 (+0200) Subject: lib-storage: Remove stub mail support X-Git-Tag: 2.3.11.2~532 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=659d51c68121cfbdc60e73b62177a7dd7ba7d4ed;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Remove stub mail support Nothing used them in the 3 years since they were introduced. --- diff --git a/src/lib-storage/index/dbox-common/dbox-save.c b/src/lib-storage/index/dbox-common/dbox-save.c index b8ef9a480a..06d6effb5f 100644 --- a/src/lib-storage/index/dbox-common/dbox-save.c +++ b/src/lib-storage/index/dbox-common/dbox-save.c @@ -17,12 +17,8 @@ void dbox_save_add_to_index(struct dbox_save_context *ctx) struct mail_save_data *mdata = &ctx->ctx.data; enum mail_flags save_flags; - if ((ctx->ctx.transaction->flags & MAILBOX_TRANSACTION_FLAG_FILL_IN_STUB) == 0) - mail_index_append(ctx->trans, mdata->uid, &ctx->seq); - else - ctx->seq = mdata->stub_seq; - save_flags = mdata->flags & ~MAIL_RECENT; + mail_index_append(ctx->trans, mdata->uid, &ctx->seq); mail_index_update_flags(ctx->trans, ctx->seq, MODIFY_REPLACE, save_flags); if (mdata->keywords != NULL) { diff --git a/src/lib-storage/index/dbox-single/sdbox-file.c b/src/lib-storage/index/dbox-single/sdbox-file.c index 79461835de..6907d7fbb4 100644 --- a/src/lib-storage/index/dbox-single/sdbox-file.c +++ b/src/lib-storage/index/dbox-single/sdbox-file.c @@ -146,8 +146,7 @@ static int sdbox_file_rename_attachments(struct sdbox_file *file) return ret; } -int sdbox_file_assign_uid(struct sdbox_file *file, uint32_t uid, - bool ignore_if_exists) +int sdbox_file_assign_uid(struct sdbox_file *file, uint32_t uid) { const char *p, *old_path, *dir, *new_fname, *new_path; struct stat st; @@ -163,7 +162,7 @@ int sdbox_file_assign_uid(struct sdbox_file *file, uint32_t uid, new_fname = t_strdup_printf(SDBOX_MAIL_FILE_FORMAT, uid); new_path = t_strdup_printf("%s/%s", dir, new_fname); - if (!ignore_if_exists && stat(new_path, &st) == 0) { + if (stat(new_path, &st) == 0) { mailbox_set_critical(&file->mbox->box, "sdbox: %s already exists, rebuilding index", new_path); sdbox_set_mailbox_corrupted(&file->mbox->box); diff --git a/src/lib-storage/index/dbox-single/sdbox-file.h b/src/lib-storage/index/dbox-single/sdbox-file.h index 91d4ccb24a..ba5a7f91cc 100644 --- a/src/lib-storage/index/dbox-single/sdbox-file.h +++ b/src/lib-storage/index/dbox-single/sdbox-file.h @@ -29,8 +29,7 @@ const char * sdbox_file_attachment_relpath(struct sdbox_file *file, const char *srcpath); /* Assign UID for a newly created file (by renaming it) */ -int sdbox_file_assign_uid(struct sdbox_file *file, uint32_t uid, - bool ignore_if_exists); +int sdbox_file_assign_uid(struct sdbox_file *file, uint32_t uid); int sdbox_file_create_fd(struct dbox_file *file, const char *path, bool parents); diff --git a/src/lib-storage/index/dbox-single/sdbox-save.c b/src/lib-storage/index/dbox-single/sdbox-save.c index b1b72a0ae1..6349eff1e7 100644 --- a/src/lib-storage/index/dbox-single/sdbox-save.c +++ b/src/lib-storage/index/dbox-single/sdbox-save.c @@ -246,7 +246,7 @@ static int dbox_save_assign_uids(struct sdbox_save_context *ctx, ret = seq_range_array_iter_nth(&iter, n++, &uid); i_assert(ret); - if (sdbox_file_assign_uid(sfile, uid, FALSE) < 0) + if (sdbox_file_assign_uid(sfile, uid) < 0) return -1; if (ctx->ctx.highest_pop3_uidl_seq == i+1) { index_pop3_uidl_set_max_uid(&ctx->mbox->box, @@ -257,27 +257,6 @@ static int dbox_save_assign_uids(struct sdbox_save_context *ctx, return 0; } -static int dbox_save_assign_stub_uids(struct sdbox_save_context *ctx) -{ - struct dbox_file *const *files; - unsigned int i, count; - - files = array_get(&ctx->files, &count); - for (i = 0; i < count; i++) { - struct sdbox_file *sfile = (struct sdbox_file *)files[i]; - uint32_t uid; - - mail_index_lookup_uid(ctx->ctx.trans->view, - ctx->first_saved_seq + i, &uid); - i_assert(uid != 0); - - if (sdbox_file_assign_uid(sfile, uid, TRUE) < 0) - return -1; - } - - return 0; -} - static void dbox_save_unref_files(struct sdbox_save_context *ctx) { struct dbox_file **files; @@ -319,22 +298,13 @@ int sdbox_transaction_save_commit_pre(struct mail_save_context *_ctx) dbox_save_update_header_flags(&ctx->ctx, ctx->sync_ctx->sync_view, ctx->mbox->hdr_ext_id, offsetof(struct sdbox_index_header, flags)); + /* assign UIDs for new messages */ hdr = mail_index_get_header(ctx->sync_ctx->sync_view); - - if ((_ctx->transaction->flags & MAILBOX_TRANSACTION_FLAG_FILL_IN_STUB) == 0) { - /* assign UIDs for new messages */ - mail_index_append_finish_uids(ctx->ctx.trans, hdr->next_uid, - &_t->changes->saved_uids); - if (dbox_save_assign_uids(ctx, &_t->changes->saved_uids) < 0) { - sdbox_transaction_save_rollback(_ctx); - return -1; - } - } else { - /* assign UIDs that we stashed away */ - if (dbox_save_assign_stub_uids(ctx) < 0) { - sdbox_transaction_save_rollback(_ctx); - return -1; - } + mail_index_append_finish_uids(ctx->ctx.trans, hdr->next_uid, + &_t->changes->saved_uids); + if (dbox_save_assign_uids(ctx, &_t->changes->saved_uids) < 0) { + sdbox_transaction_save_rollback(_ctx); + return -1; } _t->changes->uid_validity = hdr->uid_validity; diff --git a/src/lib-storage/index/dbox-single/sdbox-storage.c b/src/lib-storage/index/dbox-single/sdbox-storage.c index c669796a5c..01f28c681b 100644 --- a/src/lib-storage/index/dbox-single/sdbox-storage.c +++ b/src/lib-storage/index/dbox-single/sdbox-storage.c @@ -437,8 +437,7 @@ struct mail_storage sdbox_storage = { .class_flags = MAIL_STORAGE_CLASS_FLAG_FILE_PER_MSG | MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_GUIDS | MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_SAVE_GUIDS | - MAIL_STORAGE_CLASS_FLAG_BINARY_DATA | - MAIL_STORAGE_CLASS_FLAG_STUBS, + MAIL_STORAGE_CLASS_FLAG_BINARY_DATA, .event_category = &event_category_sdbox, .v = { diff --git a/src/lib-storage/mail-storage-private.h b/src/lib-storage/mail-storage-private.h index 65000e7d33..a656041381 100644 --- a/src/lib-storage/mail-storage-private.h +++ b/src/lib-storage/mail-storage-private.h @@ -106,8 +106,6 @@ enum mail_storage_class_flags { /* Storage deletes all files internally - mailbox list's delete_mailbox() shouldn't delete anything itself. */ MAIL_STORAGE_CLASS_FLAG_NO_LIST_DELETES = 0x400, - /* Storage supports stubs (used for caching purposes). */ - MAIL_STORAGE_CLASS_FLAG_STUBS = 0x800, }; struct mail_binary_cache { @@ -677,7 +675,7 @@ struct mail_save_data { time_t received_date, save_date; int received_tz_offset; - uint32_t uid, stub_seq; + uint32_t uid; char *guid, *pop3_uidl, *from_envelope; uint32_t pop3_order; diff --git a/src/lib-storage/mail-storage.c b/src/lib-storage/mail-storage.c index 2572daba94..980d88abef 100644 --- a/src/lib-storage/mail-storage.c +++ b/src/lib-storage/mail-storage.c @@ -1502,14 +1502,6 @@ static bool mailbox_try_undelete(struct mailbox *box) int mailbox_open(struct mailbox *box) { - /* check that the storage supports stubs if require them */ - if (((box->flags & MAILBOX_FLAG_USE_STUBS) != 0) && - ((box->storage->storage_class->class_flags & MAIL_STORAGE_CLASS_FLAG_STUBS) == 0)) { - mail_storage_set_error(box->storage, MAIL_ERROR_NOTPOSSIBLE, - "Mailbox does not support mail stubs"); - return -1; - } - if (mailbox_open_full(box, NULL) < 0) { if (!box->mailbox_deleted || box->mailbox_undeleting) return -1; @@ -2361,9 +2353,6 @@ mailbox_transaction_begin(struct mailbox *box, { 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++; @@ -2540,11 +2529,6 @@ void mailbox_save_set_from_envelope(struct mail_save_context *ctx, 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)) - 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) @@ -2588,11 +2572,6 @@ int mailbox_save_begin(struct mail_save_context **ctx, struct istream *input) 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); - /* make sure parts get parsed early on */ const struct mail_storage_settings *mail_set = mailbox_get_settings(box); diff --git a/src/lib-storage/mail-storage.h b/src/lib-storage/mail-storage.h index 6b66164599..328abd9dd6 100644 --- a/src/lib-storage/mail-storage.h +++ b/src/lib-storage/mail-storage.h @@ -60,11 +60,6 @@ enum mailbox_flags { quota updates (possibly resulting in broken quota). and This is useful for example when deleting entire user accounts. */ 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, /* Mailbox is created implicitly if it does not exist. */ MAILBOX_FLAG_AUTO_CREATE = 0x1000, /* Mailbox is subscribed to implicitly when it is created automatically */ @@ -212,10 +207,6 @@ enum mailbox_transaction_flags { especially means the notify plugin. This would normally be used only with _FLAG_SYNC. */ 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 {