]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Remove stub mail support
authorJosef 'Jeff' Sipek <jeff.sipek@open-xchange.com>
Wed, 11 Mar 2020 12:33:51 +0000 (14:33 +0200)
committerjeff.sipek <jeff.sipek@open-xchange.com>
Thu, 19 Mar 2020 13:50:40 +0000 (13:50 +0000)
Nothing used them in the 3 years since they were introduced.

src/lib-storage/index/dbox-common/dbox-save.c
src/lib-storage/index/dbox-single/sdbox-file.c
src/lib-storage/index/dbox-single/sdbox-file.h
src/lib-storage/index/dbox-single/sdbox-save.c
src/lib-storage/index/dbox-single/sdbox-storage.c
src/lib-storage/mail-storage-private.h
src/lib-storage/mail-storage.c
src/lib-storage/mail-storage.h

index b8ef9a480a7fbce029e01aa43ac0595ec194ee9e..06d6effb5fa6f55a671eb973a6fc4a349b8b94ca 100644 (file)
@@ -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) {
index 79461835debc284d70226ba0f0a58535fd551214..6907d7fbb458b7cace9faa5aacef8f9aaf6be271 100644 (file)
@@ -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);
index 91d4ccb24a7da61e18c4888a264fb4e79f62ed5c..ba5a7f91cc34abfb5cadfd224d940b357321225a 100644 (file)
@@ -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);
index b1b72a0ae1ef797cb34892129f8da770340370e3..6349eff1e7a89b600d6b5b5247a0d66b1cb31e8d 100644 (file)
@@ -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;
index c669796a5c2c4564a6e039fd590a1e0a71a1dd2e..01f28c681b2e832278d8951de61c099a4e4ad83b 100644 (file)
@@ -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 = {
index 65000e7d33f8d19f01669bdeef8c9e12df2f8de6..a656041381409a9d88b146709e3fccfe241a5782 100644 (file)
@@ -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;
 
index 2572daba9402deef671ea6a8e5538cd95ec0ab69..980d88abefefb518f76399dfbb5e90747f9d7a67 100644 (file)
@@ -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);
index 6b66164599b61f5e661a154370389c62cfdeae5f..328abd9dd6afba6f5ec4f3c7bcd66daeefc57049 100644 (file)
@@ -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 {