struct index_list_storage_module index_list_storage_module =
MODULE_CONTEXT_INIT(&mail_storage_module_register);
-int mailbox_list_index_view_open(struct mailbox *box, bool require_refreshed,
- struct mail_index_view **view_r,
- uint32_t *seq_r)
-{
- struct mailbox_list_index *ilist = INDEX_LIST_CONTEXT_REQUIRE(box->list);
- struct mailbox_list_index_node *node;
- struct mail_index_view *view;
- uint32_t seq;
- int ret;
-
- if (MAILBOX_IS_NEVER_IN_INDEX(box) && require_refreshed) {
- /* Optimization: Caller wants the list index to be up-to-date
- for this mailbox, but this mailbox isn't updated to the list
- index at all. */
- return 0;
- }
- if (mailbox_list_index_refresh(box->list) < 0) {
- mail_storage_copy_list_error(box->storage, box->list);
- return -1;
- }
-
- node = mailbox_list_index_lookup(box->list, box->name);
- if (node == NULL) {
- /* mailbox not found */
- return 0;
- }
-
- view = mail_index_view_open(ilist->index);
- if (mailbox_list_index_need_refresh(ilist, view)) {
- /* mailbox_list_index_refresh_later() was called.
- Can't trust the index's contents. */
- ret = 1;
- } else if (!mail_index_lookup_seq(view, node->uid, &seq)) {
- /* our in-memory tree is out of sync */
- ret = 1;
- } else if (!require_refreshed) {
- /* this operation doesn't need the index to be up-to-date */
- ret = 0;
- } else T_BEGIN {
- ret = box->v.list_index_has_changed == NULL ? 0 :
- box->v.list_index_has_changed(box, view, seq, FALSE);
- } T_END;
-
- if (ret != 0) {
- /* error / mailbox has changed. we'll need to sync it. */
- if (ret < 0)
- mailbox_list_index_refresh_later(box->list);
- else
- ilist->index_last_check_changed = TRUE;
- mail_index_view_close(&view);
- return ret < 0 ? -1 : 0;
- }
-
- *view_r = view;
- *seq_r = seq;
- return 1;
-}
-
static int
index_list_exists(struct mailbox *box, bool auto_boxes,
enum mailbox_existence *existence_r)
return mailbox_list_index_sync_end(&sync_ctx, TRUE);
}
+int mailbox_list_index_view_open(struct mailbox *box, bool require_refreshed,
+ struct mail_index_view **view_r,
+ uint32_t *seq_r)
+{
+ struct mailbox_list_index *ilist = INDEX_LIST_CONTEXT_REQUIRE(box->list);
+ struct mailbox_list_index_node *node;
+ struct mail_index_view *view;
+ uint32_t seq;
+ int ret;
+
+ if (MAILBOX_IS_NEVER_IN_INDEX(box) && require_refreshed) {
+ /* Optimization: Caller wants the list index to be up-to-date
+ for this mailbox, but this mailbox isn't updated to the list
+ index at all. */
+ return 0;
+ }
+ if (mailbox_list_index_refresh(box->list) < 0) {
+ mail_storage_copy_list_error(box->storage, box->list);
+ return -1;
+ }
+
+ node = mailbox_list_index_lookup(box->list, box->name);
+ if (node == NULL) {
+ /* mailbox not found */
+ return 0;
+ }
+
+ view = mail_index_view_open(ilist->index);
+ if (mailbox_list_index_need_refresh(ilist, view)) {
+ /* mailbox_list_index_refresh_later() was called.
+ Can't trust the index's contents. */
+ ret = 1;
+ } else if (!mail_index_lookup_seq(view, node->uid, &seq)) {
+ /* our in-memory tree is out of sync */
+ ret = 1;
+ } else if (!require_refreshed) {
+ /* this operation doesn't need the index to be up-to-date */
+ ret = 0;
+ } else T_BEGIN {
+ ret = box->v.list_index_has_changed == NULL ? 0 :
+ box->v.list_index_has_changed(box, view, seq, FALSE);
+ } T_END;
+
+ if (ret != 0) {
+ /* error / mailbox has changed. we'll need to sync it. */
+ if (ret < 0)
+ mailbox_list_index_refresh_later(box->list);
+ else
+ ilist->index_last_check_changed = TRUE;
+ mail_index_view_close(&view);
+ return ret < 0 ? -1 : 0;
+ }
+
+ *view_r = view;
+ *seq_r = seq;
+ return 1;
+}
+
static void mailbox_list_index_deinit(struct mailbox_list *list)
{
struct mailbox_list_index *ilist = INDEX_LIST_CONTEXT_REQUIRE(list);