if (ret < 0)
return -1;
if (ret == 0) {
- mailbox_set_critical(box,
+ storage->v.set_mailbox_corrupted(box,
"Existing files in alt path, "
"rebuilding storage to avoid losing messages");
- storage->v.set_mailbox_corrupted(box);
return -1;
}
/* dir is empty, ignore it */
"-<mailbox_guid>-<uid>" */
const char *(*get_attachment_path_suffix)(struct dbox_file *file);
/* mark the mailbox corrupted */
- void (*set_mailbox_corrupted)(struct mailbox *box);
+ void (*set_mailbox_corrupted)(struct mailbox *box, const char *reason);
/* mark the file corrupted */
void (*set_file_corrupted)(struct dbox_file *file, const char *reason);
};
return "";
}
-void mdbox_set_mailbox_corrupted(struct mailbox *box)
+void mdbox_set_mailbox_corrupted(struct mailbox *box, const char *reason)
{
struct mdbox_storage *mstorage = MDBOX_STORAGE(box->storage);
+ mailbox_set_critical(box, "%s", reason);
mdbox_storage_set_corrupted(mstorage);
}
int mdbox_mailbox_open(struct mailbox *box);
void mdbox_storage_set_corrupted(struct mdbox_storage *storage);
-void mdbox_set_mailbox_corrupted(struct mailbox *box);
+void mdbox_set_mailbox_corrupted(struct mailbox *box, const char *reason);
void mdbox_set_file_corrupted(struct dbox_file *file, const char *reason);
#endif
new_path = t_strdup_printf("%s/%s", dir, new_fname);
if (stat(new_path, &st) == 0) {
- mailbox_set_critical(&file->mbox->box,
- "sdbox: %s already exists, rebuilding index", new_path);
- sdbox_set_mailbox_corrupted(&file->mbox->box);
+ sdbox_set_mailbox_corrupted(&file->mbox->box, t_strdup_printf(
+ "%s already exists, rebuilding index", new_path));
return -1;
}
if (rename(old_path, new_path) < 0) {
return;
}
- mail_set_critical(_mail, "dbox: Unexpectedly lost uid");
- sdbox_set_mailbox_corrupted(_mail->box);
+ sdbox_set_mailbox_corrupted(_mail->box, t_strdup_printf(
+ "Unexpectedly lost uid %u", _mail->uid));
}
static int sdbox_mail_file_set(struct dbox_mail *mail)
/* it doesn't have input stream yet */
ret = dbox_file_open(mail->open_file, &deleted);
if (ret <= 0) {
- mail_set_critical(_mail,
- "dbox: Unexpectedly lost mail being saved");
- sdbox_set_mailbox_corrupted(_mail->box);
+ sdbox_set_mailbox_corrupted(_mail->box,
+ "Unexpectedly lost mail being saved");
return -1;
}
return 1;
file->uid);
}
-void sdbox_set_mailbox_corrupted(struct mailbox *box)
+void sdbox_set_mailbox_corrupted(struct mailbox *box, const char *reason)
{
struct sdbox_mailbox *mbox = SDBOX_MAILBOX(box);
struct sdbox_index_header hdr;
bool need_resize;
+ mailbox_set_critical(box, "%s", reason);
if (sdbox_read_header(mbox, &hdr, TRUE, &need_resize) < 0 ||
hdr.rebuild_count == 0)
mbox->corrupted_rebuild_count = 1;
{
struct sdbox_file *file = (struct sdbox_file *)_file;
- mail_storage_set_critical(&_file->storage->storage, "%s", reason);
- sdbox_set_mailbox_corrupted(&file->mbox->box);
+ sdbox_set_mailbox_corrupted(&file->mbox->box, reason);
}
static int sdbox_mailbox_alloc_index(struct sdbox_mailbox *mbox)
int sdbox_mailbox_create_indexes(struct mailbox *box,
const struct mailbox_update *update,
struct mail_index_transaction *trans);
-void sdbox_set_mailbox_corrupted(struct mailbox *box);
+void sdbox_set_mailbox_corrupted(struct mailbox *box, const char *reason);
struct mail_save_context *
sdbox_save_alloc(struct mailbox_transaction_context *_t);
return -1;
return 1;
}
- mailbox_set_critical(box,
+ sdbox_set_mailbox_corrupted(box,
"sdbox: Broken index: missing UIDVALIDITY");
- sdbox_set_mailbox_corrupted(box);
return 0;
}
ret = index_storage_expunged_sync_begin(&mbox->box,
&ctx->index_sync_ctx, &ctx->sync_view,
&ctx->trans, sync_flags);
- if (mail_index_reset_fscked(mbox->box.index))
- sdbox_set_mailbox_corrupted(&mbox->box);
+ if (mail_index_reset_fscked(mbox->box.index)) {
+ sdbox_set_mailbox_corrupted(&mbox->box,
+ "Mailbox index was fsck'd");
+ }
if (ret <= 0) {
array_free(&ctx->expunged_uids);
i_free(ctx);
int ret = 0;
if (mail_index_reset_fscked(box->index))
- sdbox_set_mailbox_corrupted(box);
+ sdbox_set_mailbox_corrupted(box, "Mailbox index was fsck'd");
if (index_mailbox_want_full_sync(&mbox->box, flags) ||
mbox->corrupted_rebuild_count != 0) {
if ((flags & MAILBOX_SYNC_FLAG_FORCE_RESYNC) != 0)