From: Timo Sirainen Date: Sun, 19 May 2013 20:42:29 +0000 (+0300) Subject: lib-storage: Added mailbox_status.have_save_guids. X-Git-Tag: 2.2.2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9847ec56efa15fa063eea9988eee2d4ed9ec7d58;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Added mailbox_status.have_save_guids. --- diff --git a/src/lib-storage/index/dbox-multi/mdbox-storage.c b/src/lib-storage/index/dbox-multi/mdbox-storage.c index 81e0fdf47c..a6be1f48bd 100644 --- a/src/lib-storage/index/dbox-multi/mdbox-storage.c +++ b/src/lib-storage/index/dbox-multi/mdbox-storage.c @@ -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, diff --git a/src/lib-storage/index/dbox-single/sdbox-storage.c b/src/lib-storage/index/dbox-single/sdbox-storage.c index 2de104f1ad..6e14f74d91 100644 --- a/src/lib-storage/index/dbox-single/sdbox-storage.c +++ b/src/lib-storage/index/dbox-single/sdbox-storage.c @@ -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, diff --git a/src/lib-storage/index/maildir/maildir-storage.c b/src/lib-storage/index/maildir/maildir-storage.c index 8924617865..1a076635e2 100644 --- a/src/lib-storage/index/maildir/maildir-storage.c +++ b/src/lib-storage/index/maildir/maildir-storage.c @@ -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, diff --git a/src/lib-storage/mail-storage-private.h b/src/lib-storage/mail-storage-private.h index a1ffe251e0..4b50d5f6e9 100644 --- a/src/lib-storage/mail-storage-private.h +++ b/src/lib-storage/mail-storage-private.h @@ -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 { diff --git a/src/lib-storage/mail-storage.c b/src/lib-storage/mail-storage.c index e6d14dad7c..bd4cd71dd3 100644 --- a/src/lib-storage/mail-storage.c +++ b/src/lib-storage/mail-storage.c @@ -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, diff --git a/src/lib-storage/mail-storage.h b/src/lib-storage/mail-storage.h index 4e414a53d8..0a5d5b40d5 100644 --- a/src/lib-storage/mail-storage.h +++ b/src/lib-storage/mail-storage.h @@ -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 { diff --git a/src/plugins/virtual/virtual-storage.c b/src/plugins/virtual/virtual-storage.c index 6249f8c277..662a40f1f2 100644 --- a/src/plugins/virtual/virtual-storage.c +++ b/src/plugins/virtual/virtual-storage.c @@ -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; } diff --git a/src/plugins/virtual/virtual-storage.h b/src/plugins/virtual/virtual-storage.h index 2ceaba6b00..4ebda091f6 100644 --- a/src/plugins/virtual/virtual-storage.h +++ b/src/plugins/virtual/virtual-storage.h @@ -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,