This allows getting it lazily only when it's actually needed.
NULL,
NULL,
NULL,
+ NULL,
index_mail_alloc,
index_header_lookup_init,
index_header_lookup_deinit,
NULL,
NULL,
NULL,
+ NULL,
dbox_mail_alloc,
index_header_lookup_init,
index_header_lookup_deinit,
NULL,
NULL,
NULL,
+ NULL,
dbox_mail_alloc,
index_header_lookup_init,
index_header_lookup_deinit,
if (box->backend_readonly) {
/* return read-only only if there are no private flags
(that are stored in index files) */
- if (box->private_flags_mask == 0)
+ if (mailbox_get_private_flags_mask(box) == 0)
return TRUE;
}
return FALSE;
static int maildir_mailbox_open_existing(struct mailbox *box)
{
struct maildir_mailbox *mbox = (struct maildir_mailbox *)box;
- const char *shared_path, *box_path = mailbox_get_path(box);
- struct stat st;
+ const char *box_path = mailbox_get_path(box);
mbox->uidlist = maildir_uidlist_init(mbox);
mbox->keywords = maildir_keywords_init(mbox);
- shared_path = t_strconcat(box_path, "/dovecot-shared", NULL);
- if (stat(shared_path, &st) == 0)
- box->private_flags_mask = MAIL_SEEN;
-
if ((box->flags & MAILBOX_FLAG_KEEP_LOCKED) != 0) {
if (maildir_uidlist_lock(mbox->uidlist) <= 0)
return -1;
return mailbox_uidvalidity_next(list, path);
}
+static enum mail_flags maildir_get_private_flags_mask(struct mailbox *box)
+{
+ struct maildir_mailbox *mbox = (struct maildir_mailbox *)box;
+ const char *path;
+ struct stat st;
+
+ if (!mbox->private_flags_mask_set) {
+ path = t_strconcat(mailbox_get_path(box), "/dovecot-shared", NULL);
+ if (stat(path, &st) < 0)
+ mbox->_private_flags_mask = 0;
+ else
+ mbox->_private_flags_mask = MAIL_SEEN;
+ }
+ return mbox->_private_flags_mask;
+}
+
struct mail_storage maildir_storage = {
.name = MAILDIR_STORAGE_NAME,
.class_flags = 0,
NULL,
NULL,
NULL,
+ maildir_get_private_flags_mask,
index_mail_alloc,
index_header_lookup_init,
index_header_lookup_deinit,
struct timeout *keep_lock_to;
+ /* Filled lazily by mailbox_get_private_flags_mask() */
+ enum mail_flags _private_flags_mask;
+
/* maildir sync: */
struct maildir_uidlist *uidlist;
struct maildir_keywords *keywords;
unsigned int synced:1;
unsigned int syncing_commit:1;
+ unsigned int private_flags_mask_set:1;
};
extern struct mail_vfuncs maildir_mail_vfuncs;
int ret = 0;
time_t time_before_sync;
uint8_t expunged_guid_128[MAIL_GUID_128_SIZE];
+ enum mail_flags private_flags_mask;
bool expunged, full_rescan = FALSE;
i_assert(!mbox->syncing_commit);
}
hdr_next_uid = hdr->next_uid;
+ private_flags_mask = mailbox_get_private_flags_mask(&mbox->box);
time_before_sync = time(NULL);
mbox->syncing_commit = TRUE;
seq = prev_uid = 0; first_recent_uid = I_MAX(hdr->first_recent_uid, 1);
/* the private flags are kept only in indexes. don't use them
at all even for newly seen mails */
- ctx->flags &= ~mbox->box.private_flags_mask;
+ ctx->flags &= ~private_flags_mask;
again:
seq++;
}
/* the private flags are stored only in indexes, keep them */
- ctx->flags |= rec->flags & mbox->box.private_flags_mask;
+ ctx->flags |= rec->flags & private_flags_mask;
if (index_sync_changes_have(ctx->sync_changes)) {
/* apply flag changes to maildir */
NULL,
NULL,
NULL,
+ NULL,
index_mail_alloc,
index_header_lookup_init,
index_header_lookup_deinit,
NULL,
NULL,
NULL,
+ NULL,
index_mail_alloc,
index_header_lookup_init,
index_header_lookup_deinit,
void (*get_virtual_box_patterns)(struct mailbox *box,
ARRAY_TYPE(mailbox_virtual_patterns) *includes,
ARRAY_TYPE(mailbox_virtual_patterns) *excludes);
+ enum mail_flags (*get_private_flags_mask)(struct mailbox *box);
struct mail *
(*mail_alloc)(struct mailbox_transaction_context *t,
unsigned int transaction_count;
enum mailbox_feature enabled_features;
- /* User's private flags if this is a shared mailbox */
- enum mail_flags private_flags_mask;
-
/* Mailbox notification settings: */
unsigned int notify_min_interval;
mailbox_notify_callback_t *notify_callback;
return 0;
}
+enum mail_flags mailbox_get_private_flags_mask(struct mailbox *box)
+{
+ if (box->v.get_private_flags_mask == NULL)
+ return 0;
+ else
+ return box->v.get_private_flags_mask(box);
+}
+
struct mailbox_sync_context *
mailbox_sync_init(struct mailbox *box, enum mailbox_sync_flags flags)
{
struct mailbox_status *status_r);
/* Get mailbox GUID, creating it if necessary. */
int mailbox_get_guid(struct mailbox *box, uint8_t guid[MAIL_GUID_128_SIZE]);
+/* Returns a mask of flags that are private to user in this mailbox
+ (as opposed to flags shared between users). */
+enum mail_flags mailbox_get_private_flags_mask(struct mailbox *box);
/* Synchronize the mailbox. */
struct mailbox_sync_context *
NULL,
NULL,
NULL,
+ NULL,
test_mailbox_mail_alloc,
test_mailbox_header_lookup_init,
test_mailbox_header_lookup_deinit,
{
struct acl_mailbox *abox = ACL_CONTEXT(box);
enum acl_storage_rights save_right;
+ enum mail_flags private_flags_mask;
if (abox->module_ctx.super.is_readonly(box))
return TRUE;
/* Next up is the "shared flag rights" */
if (acl_mailbox_right_lookup(box, ACL_STORAGE_RIGHT_WRITE) > 0)
return FALSE;
- if ((box->private_flags_mask & MAIL_DELETED) == 0 &&
+
+ private_flags_mask = mailbox_get_private_flags_mask(box);
+ if ((private_flags_mask & MAIL_DELETED) == 0 &&
acl_mailbox_right_lookup(box, ACL_STORAGE_RIGHT_WRITE_DELETED) > 0)
return FALSE;
- if ((box->private_flags_mask & MAIL_SEEN) == 0 &&
+ if ((private_flags_mask & MAIL_SEEN) == 0 &&
acl_mailbox_right_lookup(box, ACL_STORAGE_RIGHT_WRITE_SEEN) > 0)
return FALSE;
virtual_get_virtual_uid,
virtual_get_virtual_backend_boxes,
virtual_get_virtual_box_patterns,
+ NULL,
virtual_mail_alloc,
index_header_lookup_init,
index_header_lookup_deinit,