mailbox-list-index-status.c (dovecot-2.3.16) | : | mailbox-list-index-status.c (dovecot-2.3.17) | ||
---|---|---|---|---|
skipping to change at line 170 | skipping to change at line 170 | |||
struct index_list_mailbox *ibox = INDEX_LIST_STORAGE_CONTEXT(box); | struct index_list_mailbox *ibox = INDEX_LIST_STORAGE_CONTEXT(box); | |||
if ((items & ENUM_NEGATE(CACHED_STATUS_ITEMS)) == 0 && !box->opened) { | if ((items & ENUM_NEGATE(CACHED_STATUS_ITEMS)) == 0 && !box->opened) { | |||
if (index_list_get_cached_status(box, items, status_r) > 0) | if (index_list_get_cached_status(box, items, status_r) > 0) | |||
return 0; | return 0; | |||
/* nonsynced / error, fallback to doing it the slow way */ | /* nonsynced / error, fallback to doing it the slow way */ | |||
} | } | |||
return ibox->module_ctx.super.get_status(box, items, status_r); | return ibox->module_ctx.super.get_status(box, items, status_r); | |||
} | } | |||
/* Opportunistic function to see ïf we can extract guid from mailbox path */ | ||||
static bool index_list_get_guid_from_path(struct mailbox *box, guid_128_t guid_r | ||||
) | ||||
{ | ||||
const char *path; | ||||
if (mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_MAILBOX, &path) <= 0) | ||||
return FALSE; | ||||
const char *ptr = strrchr(path, '/'); | ||||
if (ptr == NULL) | ||||
return FALSE; | ||||
return guid_128_from_string(ptr + 1, guid_r) == 0; | ||||
} | ||||
static int | static int | |||
index_list_get_cached_guid(struct mailbox *box, guid_128_t guid_r) | index_list_get_cached_guid(struct mailbox *box, guid_128_t guid_r) | |||
{ | { | |||
struct mailbox_list_index *ilist = INDEX_LIST_CONTEXT_REQUIRE(box->list); | struct mailbox_list_index *ilist = INDEX_LIST_CONTEXT_REQUIRE(box->list); | |||
struct mailbox_status status; | struct mailbox_status status; | |||
struct mail_index_view *view; | struct mail_index_view *view; | |||
uint32_t seq; | uint32_t seq; | |||
int ret; | int ret; | |||
/* If using INDEX layout, try determine GUID from mailbox path */ | ||||
if (!ilist->has_backing_store && | ||||
index_list_get_guid_from_path(box, guid_r)) | ||||
return 1; | ||||
if (ilist->syncing) { | if (ilist->syncing) { | |||
/* syncing wants to know the GUID for a new mailbox. */ | /* syncing wants to know the GUID for a new mailbox. */ | |||
return 0; | return 0; | |||
} | } | |||
if ((ret = mailbox_list_index_view_open(box, FALSE, &view, &seq)) <= 0) | if ((ret = mailbox_list_index_view_open(box, FALSE, &view, &seq)) <= 0) | |||
return ret; | return ret; | |||
ret = mailbox_list_index_status(box->list, view, seq, 0, | ret = mailbox_list_index_status(box->list, view, seq, 0, | |||
&status, guid_r, NULL) ? 1 : 0; | &status, guid_r, NULL) ? 1 : 0; | |||
End of changes. 2 change blocks. | ||||
0 lines changed or deleted | 18 lines changed or added |