Skip to content

Commit

Permalink
#149: doveadm force-resync -u <user> INBOX
Browse files Browse the repository at this point in the history
- force-resync ignores the mailbox parameter like mdbox does and
performes does a force-resync for all user mailboxes.
  • Loading branch information
jrse committed Jun 14, 2018
1 parent 2dce0c0 commit 08d0cad
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
43 changes: 43 additions & 0 deletions src/storage-rbox/rbox-sync-rebuild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,49 @@ int rbox_sync_index_rebuild_objects(struct index_rebuild_context *ctx) {
return ret;
}

static int repair_namespace(struct mail_namespace *ns, bool force) {
FUNC_START();
struct mailbox_list_iterate_context *iter;
const struct mailbox_info *info;
int ret = 0;

iter = mailbox_list_iter_init(ns->list, "*", MAILBOX_LIST_ITER_RAW_LIST | MAILBOX_LIST_ITER_RETURN_NO_FLAGS);
while ((info = mailbox_list_iter_next(iter)) != NULL) {
if ((info->flags & (MAILBOX_NONEXISTENT | MAILBOX_NOSELECT)) == 0) {
struct mailbox *box = mailbox_alloc(ns->list, info->vname, MAILBOX_FLAG_SAVEONLY);

if (mailbox_open(box) < 0) {
return -1;
}
struct rbox_mailbox *mbox = (struct rbox_mailbox *)box;
ret = rbox_sync_index_rebuild(mbox, force);
if (ret < 0) {
i_error("error resync %s", info->vname);
}
mailbox_free(&box);
}
}
if (mailbox_list_iter_deinit(&iter) < 0) {
ret = -1;
}

FUNC_END();
return ret;
}

int rbox_storage_rebuild_in_context(struct rbox_storage *storage, bool force) {
FUNC_START();

struct mail_user *user = storage->storage.user;

struct mail_namespace *ns = mail_namespace_find_inbox(user->namespaces);
for (; ns != NULL; ns = ns->next) {
repair_namespace(ns, force);
}

FUNC_END();
}

int rbox_sync_index_rebuild(struct rbox_mailbox *mbox, bool force) {
struct index_rebuild_context *ctx;
struct mail_index_view *view;
Expand Down
1 change: 1 addition & 0 deletions src/storage-rbox/rbox-sync-rebuild.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ extern int rbox_sync_rebuild_entry(struct index_rebuild_context *ctx, librados::
bool alt_storage, bool generate_guid);
extern int rbox_sync_index_rebuild(struct rbox_mailbox *mbox, bool force);
extern int search_objects(struct index_rebuild_context *ctx, bool alt_storage);
extern int rbox_storage_rebuild_in_context(struct rbox_storage *storage, bool force);
#endif // SRC_STORAGE_RBOX_RBOX_SYNC_REBUILD_H_
2 changes: 1 addition & 1 deletion src/storage-rbox/rbox-sync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ int rbox_sync_begin(struct rbox_mailbox *mbox, struct rbox_sync_context **ctx_r,
} else {
/* do a full resync and try again. */
rebuild = FALSE;
ret = rbox_sync_index_rebuild(mbox, force_rebuild);
ret = rbox_storage_rebuild_in_context(mbox->storage, force_rebuild);
}
}
mail_index_sync_rollback(&ctx->index_sync_ctx);
Expand Down

0 comments on commit 08d0cad

Please sign in to comment.