]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Don't enforce creation of vsize header.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 4 Jun 2018 16:37:15 +0000 (19:37 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 4 Jun 2018 17:37:01 +0000 (20:37 +0300)
It's useful for caching quota=count and for STATUS (X-SIZE). If neither is
used the header shouldn't be created and kept up-to-date. If the header is
enabled, it also triggers creation of per-email vsize records.

src/lib-storage/index/index-mailbox-size.c

index 45d2d8dbd954c5accd1e26b23114795bb63d6bd4..8afdeaf9000fb92fb3690de2d9d8c9864e3eb9ea 100644 (file)
@@ -46,6 +46,7 @@ struct mailbox_vsize_update {
 
        struct file_lock *lock;
        bool lock_failed;
+       bool skip_write;
        bool rebuild;
        bool written;
        bool finish_in_background;
@@ -223,7 +224,7 @@ void index_mailbox_vsize_update_deinit(struct mailbox_vsize_update **_update)
 
        *_update = NULL;
 
-       if (update->lock != NULL || update->rebuild)
+       if ((update->lock != NULL || update->rebuild) && !update->skip_write)
                index_mailbox_vsize_update_write(update);
        file_lock_free(&update->lock);
        if (update->finish_in_background)
@@ -445,6 +446,10 @@ void index_mailbox_vsize_update_appends(struct mailbox *box)
        struct mailbox_status status;
 
        update = index_mailbox_vsize_update_init(box);
+       if (update->rebuild) {
+               /* The vsize header doesn't exist. Don't create it. */
+               update->skip_write = TRUE;
+       }
 
        /* update here only if we don't need to rebuild the whole vsize. */
        index_mailbox_vsize_check_rebuild(update);