]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Added mailbox_status.have_save_guids.
authorTimo Sirainen <tss@iki.fi>
Sun, 19 May 2013 20:42:29 +0000 (23:42 +0300)
committerTimo Sirainen <tss@iki.fi>
Sun, 19 May 2013 20:42:29 +0000 (23:42 +0300)
src/lib-storage/index/dbox-multi/mdbox-storage.c
src/lib-storage/index/dbox-single/sdbox-storage.c
src/lib-storage/index/maildir/maildir-storage.c
src/lib-storage/mail-storage-private.h
src/lib-storage/mail-storage.c
src/lib-storage/mail-storage.h
src/plugins/virtual/virtual-storage.c
src/plugins/virtual/virtual-storage.h

index 81e0fdf47c197544cde10a4d3b5ce198b337b7d5..a6be1f48bdacb4c33532ba3b6cf8c43d50d1f6b6 100644 (file)
@@ -410,7 +410,8 @@ mdbox_mailbox_update(struct mailbox *box, const struct mailbox_update *update)
 struct mail_storage mdbox_storage = {
        .name = MDBOX_STORAGE_NAME,
        .class_flags = MAIL_STORAGE_CLASS_FLAG_UNIQUE_ROOT |
-               MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_GUIDS,
+               MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_GUIDS |
+               MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_SAVE_GUIDS,
 
        .v = {
                 mdbox_get_setting_parser_info,
index 2de104f1ad8e045a2e55f15f5961e6db737260fc..6e14f74d918eee7f060903863978fe1a50154441 100644 (file)
@@ -390,7 +390,8 @@ dbox_mailbox_update(struct mailbox *box, const struct mailbox_update *update)
 struct mail_storage sdbox_storage = {
        .name = SDBOX_STORAGE_NAME,
        .class_flags = MAIL_STORAGE_CLASS_FLAG_FILE_PER_MSG |
-               MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_GUIDS,
+               MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_GUIDS |
+               MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_SAVE_GUIDS,
 
        .v = {
                 NULL,
index 89246178650a8f60daaf80b9dedc581de8dd228b..1a076635e2439f3f6ed25677cc8d197b650018ca 100644 (file)
@@ -657,7 +657,8 @@ bool maildir_is_backend_readonly(struct maildir_mailbox *mbox)
 struct mail_storage maildir_storage = {
        .name = MAILDIR_STORAGE_NAME,
        .class_flags = MAIL_STORAGE_CLASS_FLAG_FILE_PER_MSG |
-               MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_GUIDS,
+               MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_GUIDS |
+               MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_SAVE_GUIDS,
 
        .v = {
                 maildir_get_setting_parser_info,
index a1ffe251e0aac569f4ee1386298661cc7a17b5a3..4b50d5f6e98a1569a888e0efa6d1eb1bf6a105b1 100644 (file)
@@ -66,7 +66,10 @@ enum mail_storage_class_flags {
        /* Storage uses one file per message */
        MAIL_STORAGE_CLASS_FLAG_FILE_PER_MSG    = 0x20,
        /* Messages have GUIDs (always set mailbox_status.have_guids=TRUE) */
-       MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_GUIDS = 0x40
+       MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_GUIDS = 0x40,
+       /* mailbox_save_set_guid() works (always set
+          mailbox_status.have_save_guids=TRUE) */
+       MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_SAVE_GUIDS    = 0x80
 };
 
 struct mail_binary_cache {
index e6d14dad7cd14ea8cb7ce45c92360b5fae12231d..bd4cd71dd3412805a3661e7547aa56fe812c2769 100644 (file)
@@ -1471,6 +1471,8 @@ mailbox_get_status_set_defaults(struct mailbox *box,
        memset(status_r, 0, sizeof(*status_r));
        if ((box->storage->class_flags & MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_GUIDS) != 0)
                status_r->have_guids = TRUE;
+       if ((box->storage->class_flags & MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_SAVE_GUIDS) != 0)
+               status_r->have_save_guids = TRUE;
 }
 
 int mailbox_get_status(struct mailbox *box,
@@ -1480,7 +1482,10 @@ int mailbox_get_status(struct mailbox *box,
        mailbox_get_status_set_defaults(box, status_r);
        if (mailbox_verify_existing_name(box) < 0)
                return -1;
-       return box->v.get_status(box, items, status_r);
+       if (box->v.get_status(box, items, status_r) < 0)
+               return -1;
+       i_assert(status_r->have_guids || !status_r->have_save_guids);
+       return 0;
 }
 
 void mailbox_get_open_status(struct mailbox *box,
index 4e414a53d8bc4a791b968a88f66af7a0f053ebd9..0a5d5b40d5735c9d05578f5de58f592779b4bb9a 100644 (file)
@@ -275,6 +275,8 @@ struct mailbox_status {
 
        /* Messages have GUIDs (always set) */
        unsigned int have_guids:1;
+       /* mailbox_save_set_guid() works (always set) */
+       unsigned int have_save_guids:1;
 };
 
 struct mailbox_cache_field {
index 6249f8c277bcdb023fec0e3701957448464a275f..662a40f1f29910178f303adbf27b41806bfa32b1 100644 (file)
@@ -182,6 +182,8 @@ static int virtual_backend_box_open(struct virtual_mailbox *mbox,
        mailbox_get_open_status(bbox->box, 0, &status);
        if (!status.have_guids)
                mbox->have_guids = FALSE;
+       if (!status.have_save_guids)
+               mbox->have_save_guids = FALSE;
        return 1;
 }
 
@@ -193,6 +195,7 @@ static int virtual_mailboxes_open(struct virtual_mailbox *mbox,
        int ret;
 
        mbox->have_guids = TRUE;
+       mbox->have_save_guids = TRUE;
 
        bboxes = array_get(&mbox->backend_boxes, &count);
        for (i = 0; i < count; ) {
@@ -365,6 +368,8 @@ virtual_storage_get_status(struct mailbox *box,
        }
        if (mbox->have_guids)
                status_r->have_guids = TRUE;
+       if (mbox->have_save_guids)
+               status_r->have_save_guids = TRUE;
        return 0;
 }
 
index 2ceaba6b00045b5dc3389a8809a5c110b4091b96..4ebda091f6f6efe8441dbf6e37d463729a8b8538 100644 (file)
@@ -145,6 +145,7 @@ struct virtual_mailbox {
        unsigned int sync_initialized:1;
        unsigned int inconsistent:1;
        unsigned int have_guids:1;
+       unsigned int have_save_guids:1;
 };
 
 extern MODULE_CONTEXT_DEFINE(virtual_storage_module,