Skip to content

Commit

Permalink
lib-storage: mailbox_list_index_handle_corruption() - Move actual han…
Browse files Browse the repository at this point in the history
…dling to its own function
  • Loading branch information
sirainen committed Feb 19, 2018
1 parent e78c6f8 commit 98a0236
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions src/lib-storage/list/mailbox-list-index.c
Expand Up @@ -588,12 +588,31 @@ void mailbox_list_index_refresh_later(struct mailbox_list *list)
}
}

static int
list_handle_corruption_locked(struct mailbox_list *list,
enum mail_storage_list_index_rebuild_reason reason)
{
struct mail_storage *const *storagep;

array_foreach(&list->ns->all_storages, storagep) {
if ((*storagep)->v.list_index_rebuild != NULL) {
if ((*storagep)->v.list_index_rebuild(*storagep, reason) < 0)
return -1;
else {
/* FIXME: implement a generic handler that
just lists mailbox directories in filesystem
and adds the missing ones to the index. */
}
}
}
return mailbox_list_index_set_uncorrupted(list);
}

int mailbox_list_index_handle_corruption(struct mailbox_list *list)
{
struct mailbox_list_index *ilist = INDEX_LIST_CONTEXT_REQUIRE(list);
struct mail_storage *const *storagep;
enum mail_storage_list_index_rebuild_reason reason;
int ret = 0;
int ret;

if (ilist->call_corruption_callback)
reason = MAIL_STORAGE_LIST_INDEX_REBUILD_REASON_CORRUPTED;
Expand All @@ -606,20 +625,7 @@ int mailbox_list_index_handle_corruption(struct mailbox_list *list)
if (ilist->handling_corruption)
return 0;
ilist->handling_corruption = TRUE;

array_foreach(&list->ns->all_storages, storagep) {
if ((*storagep)->v.list_index_rebuild != NULL) {
if ((*storagep)->v.list_index_rebuild(*storagep, reason) < 0)
ret = -1;
else {
/* FIXME: implement a generic handler that
just lists mailbox directories in filesystem
and adds the missing ones to the index. */
}
}
}
if (ret == 0)
ret = mailbox_list_index_set_uncorrupted(list);
ret = list_handle_corruption_locked(list, reason);
ilist->handling_corruption = FALSE;
return ret;
}
Expand Down

0 comments on commit 98a0236

Please sign in to comment.