]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: mailbox_copy() didn't always copy all the cached fields to destination.
authorTimo Sirainen <tss@iki.fi>
Thu, 18 Apr 2013 14:48:38 +0000 (17:48 +0300)
committerTimo Sirainen <tss@iki.fi>
Thu, 18 Apr 2013 14:48:38 +0000 (17:48 +0300)
If the destination mailbox's cache file wasn't already opened, the default
cache decisions were used.

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

index ce45207fd32c99f1f5ebda5eb17c6eca1d0599cd..047ae6c5df435d4b984f7a531e71862d6bb33288 100644 (file)
@@ -806,7 +806,7 @@ void index_copy_cache_fields(struct mail_save_context *ctx,
                             struct mail *src_mail, uint32_t dest_seq)
 {
        T_BEGIN {
-               struct mailbox_metadata src_metadata;
+               struct mailbox_metadata src_metadata, dest_metadata;
                const struct mailbox_cache_field *field;
                buffer_t *buf;
 
@@ -814,6 +814,13 @@ void index_copy_cache_fields(struct mail_save_context *ctx,
                                         MAILBOX_METADATA_CACHE_FIELDS,
                                         &src_metadata) < 0)
                        i_unreached();
+               /* the only reason we're doing the destination lookup is to
+                  make sure that the cache file is opened and the cache
+                  decisinos are up to date */
+               if (mailbox_get_metadata(ctx->transaction->box,
+                                        MAILBOX_METADATA_CACHE_FIELDS,
+                                        &dest_metadata) < 0)
+                       i_unreached();
 
                buf = buffer_create_dynamic(pool_datastack_create(), 1024);
                array_foreach(src_metadata.cache_fields, field) {