]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Added mailbox_status.have_guids flag
authorTimo Sirainen <tss@iki.fi>
Sun, 10 Feb 2013 22:26:15 +0000 (00:26 +0200)
committerTimo Sirainen <tss@iki.fi>
Sun, 10 Feb 2013 22:26:15 +0000 (00:26 +0200)
src/lib-storage/index/dbox-multi/mdbox-storage.c
src/lib-storage/index/dbox-single/sdbox-storage.c
src/lib-storage/index/imapc/imapc-storage.c
src/lib-storage/index/maildir/maildir-storage.c
src/lib-storage/index/mbox/mbox-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 dc77165b546e6d489be836e3beef20a10504a2ac..81e0fdf47c197544cde10a4d3b5ce198b337b7d5 100644 (file)
@@ -409,7 +409,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,
+       .class_flags = MAIL_STORAGE_CLASS_FLAG_UNIQUE_ROOT |
+               MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_GUIDS,
 
        .v = {
                 mdbox_get_setting_parser_info,
index 84b0fa0071590d447e27da5ca7b08a644cb02ca9..2de104f1ad8e045a2e55f15f5961e6db737260fc 100644 (file)
@@ -389,7 +389,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,
+       .class_flags = MAIL_STORAGE_CLASS_FLAG_FILE_PER_MSG |
+               MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_GUIDS,
 
        .v = {
                 NULL,
index c03fe2a8ab44b17322a6e72880c1894681d9ab12..2f009d4166815a8ed13b68d465da910d79cca9ce 100644 (file)
@@ -661,7 +661,9 @@ static int imapc_mailbox_get_status(struct mailbox *box,
        struct imapc_simple_context sctx;
        string_t *str;
 
-       memset(status_r, 0, sizeof(*status_r));
+       if (mbox->guid_fetch_field_name != NULL ||
+           IMAPC_BOX_HAS_FEATURE(mbox, IMAPC_FEATURE_GUID_FORCED))
+               status_r->have_guids = TRUE;
 
        if (box->opened) {
                imapc_mailbox_get_selected_status(mbox, items, status_r);
index 10a3fb58754165132d50f289e9cd6ad7e758b7ee..80e73d203dd725bfb6e42203cb9d460a507b4089 100644 (file)
@@ -656,7 +656,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,
+       .class_flags = MAIL_STORAGE_CLASS_FLAG_FILE_PER_MSG |
+               MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_GUIDS,
 
        .v = {
                 maildir_get_setting_parser_info,
index 170f686a4f3ec21edc0f4f297bd2cdf9497b464a..fe4c613de77c9bc8f6f52fafb6af2e9c3c6111d2 100644 (file)
@@ -791,7 +791,8 @@ bool mbox_is_backend_readonly(struct mbox_mailbox *mbox)
 struct mail_storage mbox_storage = {
        .name = MBOX_STORAGE_NAME,
        .class_flags = MAIL_STORAGE_CLASS_FLAG_MAILBOX_IS_FILE |
-               MAIL_STORAGE_CLASS_FLAG_OPEN_STREAMS,
+               MAIL_STORAGE_CLASS_FLAG_OPEN_STREAMS |
+               MAIL_STORAGE_CLASS_FLAG_HAVE_MAIL_GUIDS,
 
        .v = {
                 mbox_get_setting_parser_info,
index e627ef480bb792bec20eac7438b312c91f936f71..8d13926925b7f366fae48e7d89420bed59812903 100644 (file)
@@ -64,7 +64,9 @@ enum mail_storage_class_flags {
        /* Storage doesn't need a mail root directory */
        MAIL_STORAGE_CLASS_FLAG_NO_ROOT         = 0x10,
        /* Storage uses one file per message */
-       MAIL_STORAGE_CLASS_FLAG_FILE_PER_MSG    = 0x20
+       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
 };
 
 struct mail_binary_cache {
index 7ba79dcb58261f1d376586608c7d6df45fd7acf4..26cb1deb2e8e9c01cbc52ec4a82d3a73a0d93f20 100644 (file)
@@ -1453,11 +1453,20 @@ bool mailbox_backends_equal(const struct mailbox *box1,
        return ns1 == ns2;
 }
 
+static void
+mailbox_get_status_set_defaults(struct mailbox *box,
+                               struct mailbox_status *status_r)
+{
+       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;
+}
+
 int mailbox_get_status(struct mailbox *box,
                       enum mailbox_status_items items,
                       struct mailbox_status *status_r)
 {
-       memset(status_r, 0, sizeof(*status_r));
+       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);
@@ -1469,7 +1478,7 @@ void mailbox_get_open_status(struct mailbox *box,
 {
        i_assert(box->opened);
 
-       memset(status_r, 0, sizeof(*status_r));
+       mailbox_get_status_set_defaults(box, status_r);
        if (box->v.get_status(box, items, status_r) < 0)
                i_unreached();
 }
index 44a1dea751283a2f14d1baa30d48f30917113f59..309085b8a34e70cd28e591614b457b3cdc4827c9 100644 (file)
@@ -223,31 +223,35 @@ struct mailbox;
 struct mailbox_transaction_context;
 
 struct mailbox_status {
-       uint32_t messages;
-       uint32_t recent;
-       uint32_t unseen;
+       uint32_t messages; /* STATUS_MESSAGES */
+       uint32_t recent; /* STATUS_RECENT */
+       uint32_t unseen; /* STATUS_UNSEEN */
 
-       uint32_t uidvalidity;
-       uint32_t uidnext;
+       uint32_t uidvalidity; /* STATUS_UIDVALIDITY */
+       uint32_t uidnext; /* STATUS_UIDNEXT */
 
-       uint32_t first_unseen_seq;
-       uint32_t first_recent_uid;
-       uint32_t last_cached_seq;
-       uint64_t highest_modseq;
-       uint64_t highest_pvt_modseq; /* 0 if no private index */
+       uint32_t first_unseen_seq; /* STATUS_FIRST_UNSEEN_SEQ */
+       uint32_t first_recent_uid; /* STATUS_FIRST_RECENT_UID */
+       uint32_t last_cached_seq; /* STATUS_LAST_CACHED_SEQ */
+       uint64_t highest_modseq; /* STATUS_HIGHESTMODSEQ */
+       /* 0 if no private index (STATUS_HIGHESTPVTMODSEQ) */
+       uint64_t highest_pvt_modseq;
 
-       /* NULL-terminated array of keywords */
+       /* NULL-terminated array of keywords (STATUS_KEYWORDS) */
        const ARRAY_TYPE(keywords) *keywords;
 
-       /* These flags can be permanently modified */
+       /* These flags can be permanently modified (STATUS_PERMANENT_FLAGS) */
        enum mail_flags permanent_flags;
 
-       /* Modseqs aren't permanent (index is in memory) */
-       unsigned int nonpermanent_modseqs:1;
-       /* All keywords can be permanently modified */
+       /* All keywords can be permanently modified (STATUS_PERMANENT_FLAGS) */
        unsigned int permanent_keywords:1;
-       /* More keywords can be created */
+       /* More keywords can be created (STATUS_PERMANENT_FLAGS) */
        unsigned int allow_new_keywords:1;
+       /* Modseqs aren't permanent (index is in memory) (STATUS_HIGHESTMODSEQ) */
+       unsigned int nonpermanent_modseqs:1;
+
+       /* Messages have GUIDs (always set) */
+       unsigned int have_guids:1;
 };
 
 struct mailbox_cache_field {
index 334f0ed2cbec1c3e06aca582ca79b83ba6681474..6249f8c277bcdb023fec0e3701957448464a275f 100644 (file)
@@ -161,6 +161,7 @@ static int virtual_backend_box_open(struct virtual_mailbox *mbox,
 {
        struct mail_user *user = mbox->storage->storage.user;
        struct mail_namespace *ns;
+       struct mailbox_status status;
        const char *mailbox;
 
        i_assert(bbox->box == NULL);
@@ -177,6 +178,10 @@ static int virtual_backend_box_open(struct virtual_mailbox *mbox,
        i_array_init(&bbox->uids, 64);
        i_array_init(&bbox->sync_pending_removes, 64);
        mail_search_args_init(bbox->search_args, bbox->box, FALSE, NULL);
+
+       mailbox_get_open_status(bbox->box, 0, &status);
+       if (!status.have_guids)
+               mbox->have_guids = FALSE;
        return 1;
 }
 
@@ -187,6 +192,8 @@ static int virtual_mailboxes_open(struct virtual_mailbox *mbox,
        unsigned int i, count;
        int ret;
 
+       mbox->have_guids = TRUE;
+
        bboxes = array_get(&mbox->backend_boxes, &count);
        for (i = 0; i < count; ) {
                ret = virtual_backend_box_open(mbox, bboxes[i], flags);
@@ -339,6 +346,8 @@ virtual_storage_get_status(struct mailbox *box,
                           enum mailbox_status_items items,
                           struct mailbox_status *status_r)
 {
+       struct virtual_mailbox *mbox = (struct virtual_mailbox *)box;
+
        if ((items & STATUS_LAST_CACHED_SEQ) != 0)
                items |= STATUS_MESSAGES;
 
@@ -354,6 +363,8 @@ virtual_storage_get_status(struct mailbox *box,
                   indexed. */
                status_r->last_cached_seq = status_r->messages;
        }
+       if (mbox->have_guids)
+               status_r->have_guids = TRUE;
        return 0;
 }
 
index 248c26d4946e32baffa5912ce0c196af57b81cc0..2ceaba6b00045b5dc3389a8809a5c110b4091b96 100644 (file)
@@ -144,6 +144,7 @@ struct virtual_mailbox {
        unsigned int uids_mapped:1;
        unsigned int sync_initialized:1;
        unsigned int inconsistent:1;
+       unsigned int have_guids:1;
 };
 
 extern MODULE_CONTEXT_DEFINE(virtual_storage_module,