dovecot-2.2: lib-storage: Added mailbox_status.have_guids flag
dovecot at dovecot.org
dovecot at dovecot.org
Mon Feb 11 00:29:48 EET 2013
details: http://hg.dovecot.org/dovecot-2.2/rev/91f60f0d72df
changeset: 15749:91f60f0d72df
user: Timo Sirainen <tss at iki.fi>
date: Mon Feb 11 00:26:15 2013 +0200
description:
lib-storage: Added mailbox_status.have_guids flag
diffstat:
src/lib-storage/index/dbox-multi/mdbox-storage.c | 3 +-
src/lib-storage/index/dbox-single/sdbox-storage.c | 3 +-
src/lib-storage/index/imapc/imapc-storage.c | 4 +-
src/lib-storage/index/maildir/maildir-storage.c | 3 +-
src/lib-storage/index/mbox/mbox-storage.c | 3 +-
src/lib-storage/mail-storage-private.h | 4 +-
src/lib-storage/mail-storage.c | 13 ++++++-
src/lib-storage/mail-storage.h | 38 ++++++++++++----------
src/plugins/virtual/virtual-storage.c | 11 ++++++
src/plugins/virtual/virtual-storage.h | 1 +
10 files changed, 58 insertions(+), 25 deletions(-)
diffs (230 lines):
diff -r 490fa658b66d -r 91f60f0d72df src/lib-storage/index/dbox-multi/mdbox-storage.c
--- a/src/lib-storage/index/dbox-multi/mdbox-storage.c Mon Feb 11 00:25:29 2013 +0200
+++ b/src/lib-storage/index/dbox-multi/mdbox-storage.c Mon Feb 11 00:26:15 2013 +0200
@@ -409,7 +409,8 @@
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,
diff -r 490fa658b66d -r 91f60f0d72df src/lib-storage/index/dbox-single/sdbox-storage.c
--- a/src/lib-storage/index/dbox-single/sdbox-storage.c Mon Feb 11 00:25:29 2013 +0200
+++ b/src/lib-storage/index/dbox-single/sdbox-storage.c Mon Feb 11 00:26:15 2013 +0200
@@ -389,7 +389,8 @@
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,
diff -r 490fa658b66d -r 91f60f0d72df src/lib-storage/index/imapc/imapc-storage.c
--- a/src/lib-storage/index/imapc/imapc-storage.c Mon Feb 11 00:25:29 2013 +0200
+++ b/src/lib-storage/index/imapc/imapc-storage.c Mon Feb 11 00:26:15 2013 +0200
@@ -661,7 +661,9 @@
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);
diff -r 490fa658b66d -r 91f60f0d72df src/lib-storage/index/maildir/maildir-storage.c
--- a/src/lib-storage/index/maildir/maildir-storage.c Mon Feb 11 00:25:29 2013 +0200
+++ b/src/lib-storage/index/maildir/maildir-storage.c Mon Feb 11 00:26:15 2013 +0200
@@ -656,7 +656,8 @@
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,
diff -r 490fa658b66d -r 91f60f0d72df src/lib-storage/index/mbox/mbox-storage.c
--- a/src/lib-storage/index/mbox/mbox-storage.c Mon Feb 11 00:25:29 2013 +0200
+++ b/src/lib-storage/index/mbox/mbox-storage.c Mon Feb 11 00:26:15 2013 +0200
@@ -791,7 +791,8 @@
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,
diff -r 490fa658b66d -r 91f60f0d72df src/lib-storage/mail-storage-private.h
--- a/src/lib-storage/mail-storage-private.h Mon Feb 11 00:25:29 2013 +0200
+++ b/src/lib-storage/mail-storage-private.h Mon Feb 11 00:26:15 2013 +0200
@@ -64,7 +64,9 @@
/* 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 {
diff -r 490fa658b66d -r 91f60f0d72df src/lib-storage/mail-storage.c
--- a/src/lib-storage/mail-storage.c Mon Feb 11 00:25:29 2013 +0200
+++ b/src/lib-storage/mail-storage.c Mon Feb 11 00:26:15 2013 +0200
@@ -1453,11 +1453,20 @@
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 @@
{
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();
}
diff -r 490fa658b66d -r 91f60f0d72df src/lib-storage/mail-storage.h
--- a/src/lib-storage/mail-storage.h Mon Feb 11 00:25:29 2013 +0200
+++ b/src/lib-storage/mail-storage.h Mon Feb 11 00:26:15 2013 +0200
@@ -223,31 +223,35 @@
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) */
+ /* All keywords can be permanently modified (STATUS_PERMANENT_FLAGS) */
+ unsigned int permanent_keywords:1;
+ /* 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;
- /* All keywords can be permanently modified */
- unsigned int permanent_keywords:1;
- /* More keywords can be created */
- unsigned int allow_new_keywords:1;
+
+ /* Messages have GUIDs (always set) */
+ unsigned int have_guids:1;
};
struct mailbox_cache_field {
diff -r 490fa658b66d -r 91f60f0d72df src/plugins/virtual/virtual-storage.c
--- a/src/plugins/virtual/virtual-storage.c Mon Feb 11 00:25:29 2013 +0200
+++ b/src/plugins/virtual/virtual-storage.c Mon Feb 11 00:26:15 2013 +0200
@@ -161,6 +161,7 @@
{
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 @@
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 @@
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 @@
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 @@
indexed. */
status_r->last_cached_seq = status_r->messages;
}
+ if (mbox->have_guids)
+ status_r->have_guids = TRUE;
return 0;
}
diff -r 490fa658b66d -r 91f60f0d72df src/plugins/virtual/virtual-storage.h
--- a/src/plugins/virtual/virtual-storage.h Mon Feb 11 00:25:29 2013 +0200
+++ b/src/plugins/virtual/virtual-storage.h Mon Feb 11 00:26:15 2013 +0200
@@ -144,6 +144,7 @@
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,
More information about the dovecot-cvs
mailing list