# HG changeset patch # User Timo Sirainen # Date 1295544080 -7200 # Node ID b748c622e8962956cce7354308a43d5cad4d23bb # Parent 8dbcf27f7c08b77c13f9d898fd1cd5ffcd4ac4ef lib-storage: Added mailbox_get_last_*error() wrappers and use them. diff -r 8dbcf27f7c08 -r b748c622e896 src/doveadm/doveadm-mail-fetch.c --- a/src/doveadm/doveadm-mail-fetch.c Thu Jan 20 18:17:22 2011 +0200 +++ b/src/doveadm/doveadm-mail-fetch.c Thu Jan 20 19:21:20 2011 +0200 @@ -387,12 +387,9 @@ array_foreach(&ctx->fields, field) { ctx->cur_field = field; if (field->print(ctx) < 0) { - struct mail_storage *storage = - mailbox_get_storage(mail->box); - i_error("fetch(%s) failed for box=%s uid=%u: %s", field->name, mailbox_get_vname(mail->box), - mail->uid, mail_storage_get_last_error(storage, NULL)); + mail->uid, mailbox_get_last_error(mail->box, NULL)); } } } diff -r 8dbcf27f7c08 -r b748c622e896 src/doveadm/doveadm-mail-import.c --- a/src/doveadm/doveadm-mail-import.c Thu Jan 20 18:17:22 2011 +0200 +++ b/src/doveadm/doveadm-mail-import.c Thu Jan 20 19:21:20 2011 +0200 @@ -49,8 +49,7 @@ box = mailbox_alloc(ns->list, storage_name, MAILBOX_FLAG_SAVEONLY | MAILBOX_FLAG_KEEP_RECENT); if (mailbox_create(box, NULL, FALSE) < 0) { - errstr = mail_storage_get_last_error(mailbox_get_storage(box), - &error); + errstr = mailbox_get_last_error(box, &error); if (error != MAIL_ERROR_EXISTS) { i_error("Couldn't create mailbox %s: %s", name, errstr); mailbox_free(&box); @@ -59,8 +58,7 @@ } if (mailbox_sync(box, MAILBOX_SYNC_FLAG_FULL_READ) < 0) { i_error("Syncing mailbox %s failed: %s", name, - mail_storage_get_last_error(mailbox_get_storage(box), - NULL)); + mailbox_get_last_error(box, NULL)); mailbox_free(&box); return -1; } @@ -72,7 +70,6 @@ cmd_import_box_contents(struct doveadm_mail_iter *iter, struct mail *src_mail, struct mailbox *dest_box) { - struct mail_storage *dest_storage = mailbox_get_storage(dest_box); struct mail_save_context *save_ctx; struct mailbox_transaction_context *dest_trans; const char *mailbox = mailbox_get_vname(dest_box); @@ -89,14 +86,14 @@ if (mailbox_copy(&save_ctx, src_mail) < 0) { i_error("Copying box=%s uid=%u failed: %s", mailbox, src_mail->uid, - mail_storage_get_last_error(dest_storage, NULL)); + mailbox_get_last_error(dest_box, NULL)); ret = -1; } } while (doveadm_mail_iter_next(iter, src_mail)); if (mailbox_transaction_commit(&dest_trans) < 0) { i_error("Committing copied mails to %s failed: %s", mailbox, - mail_storage_get_last_error(dest_storage, NULL)); + mailbox_get_last_error(dest_box, NULL)); ret = -1; } return ret; diff -r 8dbcf27f7c08 -r b748c622e896 src/doveadm/doveadm-mail-iter.c --- a/src/doveadm/doveadm-mail-iter.c Thu Jan 20 18:17:22 2011 +0200 +++ b/src/doveadm/doveadm-mail-iter.c Thu Jan 20 19:21:20 2011 +0200 @@ -10,7 +10,6 @@ struct mail_search_args *search_args; struct mailbox *box; - struct mail_storage *storage; struct mailbox_transaction_context *t; struct mail_search_context *search_ctx; }; @@ -29,12 +28,11 @@ iter->box = mailbox_alloc(info->ns->list, storage_name, MAILBOX_FLAG_KEEP_RECENT | MAILBOX_FLAG_IGNORE_ACLS); - iter->storage = mailbox_get_storage(iter->box); iter->search_args = search_args; if (mailbox_sync(iter->box, MAILBOX_SYNC_FLAG_FULL_READ) < 0) { i_error("Syncing mailbox %s failed: %s", info->name, - mail_storage_get_last_error(iter->storage, NULL)); + mailbox_get_last_error(iter->box, NULL)); mailbox_free(&iter->box); i_free(iter); return -1; @@ -57,13 +55,13 @@ if (mailbox_search_deinit(&iter->search_ctx) < 0) { i_error("Searching mailbox %s failed: %s", mailbox_get_vname(iter->box), - mail_storage_get_last_error(iter->storage, NULL)); + mailbox_get_last_error(iter->box, NULL)); ret = -1; } if (mailbox_transaction_commit(&iter->t) < 0) { i_error("Commiting mailbox %s failed: %s", mailbox_get_vname(iter->box), - mail_storage_get_last_error(iter->storage, NULL)); + mailbox_get_last_error(iter->box, NULL)); ret = -1; } mail_search_args_deinit(iter->search_args); diff -r 8dbcf27f7c08 -r b748c622e896 src/doveadm/doveadm-mail-mailbox.c --- a/src/doveadm/doveadm-mail-mailbox.c Thu Jan 20 18:17:22 2011 +0200 +++ b/src/doveadm/doveadm-mail-mailbox.c Thu Jan 20 19:21:20 2011 +0200 @@ -203,10 +203,8 @@ box = mailbox_alloc(ns->list, storage_name, 0); if (mailbox_create(box, NULL, directory) < 0) { - struct mail_storage *storage = mailbox_get_storage(box); - i_error("Can't create mailbox %s: %s", *namep, - mail_storage_get_last_error(storage, NULL)); + mailbox_get_last_error(box, NULL)); } if (ctx->ctx.subscriptions) { if (mailbox_list_set_subscribed(ns->list, storage_name, @@ -265,10 +263,8 @@ box = mailbox_alloc(ns->list, storage_name, 0); if (mailbox_delete(box) < 0) { - struct mail_storage *storage = mailbox_get_storage(box); - i_error("Can't delete mailbox %s: %s", *namep, - mail_storage_get_last_error(storage, NULL)); + mailbox_get_last_error(box, NULL)); } if (ctx->ctx.subscriptions) { if (mailbox_list_set_subscribed(ns->list, storage_name, @@ -329,10 +325,8 @@ oldbox = mailbox_alloc(oldns->list, oldname, 0); newbox = mailbox_alloc(newns->list, newname, 0); if (mailbox_rename(oldbox, newbox, TRUE) < 0) { - struct mail_storage *storage = mailbox_get_storage(oldbox); - i_error("Can't rename mailbox %s to %s: %s", oldname, newname, - mail_storage_get_last_error(storage, NULL)); + mailbox_get_last_error(oldbox, NULL)); } if (ctx->ctx.subscriptions) { if (mailbox_list_set_subscribed(oldns->list, oldname, FALSE) < 0) { diff -r 8dbcf27f7c08 -r b748c622e896 src/doveadm/doveadm-mail.c --- a/src/doveadm/doveadm-mail.c Thu Jan 20 18:17:22 2011 +0200 +++ b/src/doveadm/doveadm-mail.c Thu Jan 20 19:21:20 2011 +0200 @@ -99,8 +99,7 @@ box = doveadm_mailbox_find(user, mailbox); if (mailbox_open(box) < 0) { i_error("Opening mailbox %s failed: %s", mailbox, - mail_storage_get_last_error(mailbox_get_storage(box), - NULL)); + mailbox_get_last_error(box, NULL)); mailbox_free(&box); return -1; } @@ -115,8 +114,7 @@ return -1; if (mailbox_sync(*box_r, MAILBOX_SYNC_FLAG_FULL_READ) < 0) { i_error("Syncing mailbox %s failed: %s", mailbox, - mail_storage_get_last_error(mailbox_get_storage(*box_r), - NULL)); + mailbox_get_last_error(*box_r, NULL)); mailbox_free(box_r); return -1; } @@ -148,19 +146,16 @@ { struct force_resync_cmd_context *ctx = (struct force_resync_cmd_context *)_ctx; - struct mail_storage *storage; struct mailbox *box; if (doveadm_mailbox_find_and_open(user, ctx->mailbox, &box) < 0) { _ctx->failed = TRUE; return; } - storage = mailbox_get_storage(box); if (mailbox_sync(box, MAILBOX_SYNC_FLAG_FORCE_RESYNC | MAILBOX_SYNC_FLAG_FIX_INCONSISTENT) < 0) { i_error("Forcing a resync on mailbox %s failed: %s", - ctx->mailbox, - mail_storage_get_last_error(storage, NULL)); + ctx->mailbox, mailbox_get_last_error(box, NULL)); _ctx->failed = TRUE; } mailbox_free(&box); diff -r 8dbcf27f7c08 -r b748c622e896 src/dsync/dsync-worker-local.c --- a/src/dsync/dsync-worker-local.c Thu Jan 20 18:17:22 2011 +0200 +++ b/src/dsync/dsync-worker-local.c Thu Jan 20 19:21:20 2011 +0200 @@ -561,10 +561,8 @@ box = mailbox_alloc(info->ns->list, storage_name, flags); if (mailbox_get_status(box, status_items, &status) < 0 || mailbox_get_metadata(box, metadata_items, &metadata) < 0) { - struct mail_storage *storage = mailbox_get_storage(box); - i_error("Failed to sync mailbox %s: %s", info->name, - mail_storage_get_last_error(storage, NULL)); + mailbox_get_last_error(box, NULL)); mailbox_free(&box); _iter->failed = TRUE; return -1; @@ -801,10 +799,8 @@ box = mailbox_alloc(lbox->ns->list, lbox->storage_name, flags); if (mailbox_sync(box, 0) < 0 || mailbox_get_metadata(box, MAILBOX_METADATA_GUID, &metadata) < 0) { - struct mail_storage *storage = mailbox_get_storage(box); - i_error("Failed to sync mailbox %s: %s", lbox->storage_name, - mail_storage_get_last_error(storage, NULL)); + mailbox_get_last_error(box, NULL)); mailbox_free(&box); return -1; } @@ -861,11 +857,8 @@ iter->expunges_set = FALSE; mail_free(&iter->mail); if (mailbox_search_deinit(&iter->search_ctx) < 0) { - struct mail_storage *storage = - mailbox_get_storage(iter->mail->box); - i_error("msg search failed: %s", - mail_storage_get_last_error(storage, NULL)); + mailbox_get_last_error(iter->mail->box, NULL)); iter->iter.failed = TRUE; } (void)mailbox_transaction_commit(&trans); @@ -985,11 +978,8 @@ if (mail_get_special(iter->mail, MAIL_FETCH_GUID, &guid) < 0) { if (!iter->mail->expunged) { - struct mail_storage *storage = - mailbox_get_storage(iter->mail->box); - i_error("msg guid lookup failed: %s", - mail_storage_get_last_error(storage, NULL)); + mailbox_get_last_error(iter->mail->box, NULL)); _iter->failed = TRUE; return -1; } @@ -1195,8 +1185,7 @@ } if (mailbox_create(box, &update, FALSE) < 0) { - errstr = mail_storage_get_last_error(mailbox_get_storage(box), - &error); + errstr = mailbox_get_last_error(box, &error); if (error == MAIL_ERROR_EXISTS) { /* mailbox already exists */ return 0; @@ -1274,10 +1263,8 @@ dsync_box->last_change); box = mailbox_alloc(lbox->ns->list, lbox->storage_name, 0); if (mailbox_delete(box) < 0) { - struct mail_storage *storage = mailbox_get_storage(box); - i_error("Can't delete mailbox %s: %s", lbox->storage_name, - mail_storage_get_last_error(storage, NULL)); + mailbox_get_last_error(box, NULL)); dsync_worker_set_failure(_worker); } mailbox_free(&box); @@ -1338,10 +1325,8 @@ old_box = mailbox_alloc(list, lbox->storage_name, 0); new_box = mailbox_alloc(list, newname, 0); if (mailbox_rename(old_box, new_box, FALSE) < 0) { - struct mail_storage *storage = mailbox_get_storage(old_box); - i_error("Can't rename mailbox %s to %s: %s", lbox->storage_name, - newname, mail_storage_get_last_error(storage, NULL)); + newname, mailbox_get_last_error(old_box, NULL)); dsync_worker_set_failure(_worker); } else { lbox->storage_name = p_strdup(worker->pool, newname); @@ -1445,8 +1430,7 @@ if (mailbox_update(box, &update) < 0) { dsync_worker_set_failure(_worker); i_error("Can't update mailbox %s: %s", dsync_box->name, - mail_storage_get_last_error(mailbox_get_storage(box), - NULL)); + mailbox_get_last_error(box, NULL)); } mailbox_free(&box); @@ -1668,12 +1652,9 @@ } else { i_assert(worker->save_input->eof); if (mailbox_save_finish(&worker->save_ctx) < 0) { - struct mail_storage *storage = - mailbox_get_storage(dest_box); - i_error("Can't save message to mailbox %s: %s", mailbox_get_vname(dest_box), - mail_storage_get_last_error(storage, NULL)); + mailbox_get_last_error(dest_box, NULL)); dsync_worker_set_failure(&worker->worker); } } @@ -1712,10 +1693,9 @@ mailbox_save_set_received_date(save_ctx, data->received_date, 0); if (mailbox_save_begin(&save_ctx, data->input) < 0) { - struct mail_storage *storage = mailbox_get_storage(dest_box); i_error("Can't save message to mailbox %s: %s", mailbox_get_vname(dest_box), - mail_storage_get_last_error(storage, NULL)); + mailbox_get_last_error(dest_box, NULL)); mailbox_save_cancel(&save_ctx); dsync_worker_set_failure(_worker); callback(context); diff -r 8dbcf27f7c08 -r b748c622e896 src/imap/cmd-fetch.c --- a/src/imap/cmd-fetch.c Thu Jan 20 18:17:22 2011 +0200 +++ b/src/imap/cmd-fetch.c Thu Jan 20 19:21:20 2011 +0200 @@ -145,21 +145,18 @@ ctx->failed = TRUE; if (ctx->failed) { - struct mail_storage *storage; - const char *error_string; - enum mail_error error; + const char *errstr; if (ctx->client->output->closed) { client_disconnect(cmd->client, "Disconnected"); return TRUE; } - storage = mailbox_get_storage(cmd->client->mailbox); - error_string = mail_storage_get_last_error(storage, &error); + errstr = mailbox_get_last_error(cmd->client->mailbox, NULL); /* We never want to reply NO to FETCH requests, BYE is preferrable (see imap-ml for reasons). */ - client_disconnect_with_error(cmd->client, error_string); + client_disconnect_with_error(cmd->client, errstr); return TRUE; } diff -r 8dbcf27f7c08 -r b748c622e896 src/imap/imap-commands-util.c --- a/src/imap/imap-commands-util.c Thu Jan 20 18:17:22 2011 +0200 +++ b/src/imap/imap-commands-util.c Thu Jan 20 19:21:20 2011 +0200 @@ -90,14 +90,12 @@ box = mailbox_alloc(ns->list, storage_name, MAILBOX_FLAG_SAVEONLY | MAILBOX_FLAG_KEEP_RECENT); if (mailbox_open(box) < 0) { - struct mail_storage *storage = mailbox_get_storage(box); - - error_string = mail_storage_get_last_error(storage, &error); + error_string = mailbox_get_last_error(box, &error); if (error == MAIL_ERROR_NOTFOUND) { client_send_tagline(cmd, t_strdup_printf( "NO [TRYCREATE] %s", error_string)); } else { - client_send_storage_error(cmd, storage); + client_send_storage_error(cmd, mailbox_get_storage(box)); } mailbox_free(&box); return -1; diff -r 8dbcf27f7c08 -r b748c622e896 src/imap/imap-status.c --- a/src/imap/imap-status.c Thu Jan 20 18:17:22 2011 +0200 +++ b/src/imap/imap-status.c Thu Jan 20 19:21:20 2011 +0200 @@ -92,9 +92,7 @@ } if (ret < 0) { - struct mail_storage *storage = mailbox_get_storage(box); - - *error_r = mail_storage_get_last_error(storage, &error); + *error_r = mailbox_get_last_error(box, &error); *error_r = imap_get_error_string(cmd, *error_r, error); } if (box != client->mailbox) diff -r 8dbcf27f7c08 -r b748c622e896 src/lda/main.c --- a/src/lda/main.c Thu Jan 20 18:17:22 2011 +0200 +++ b/src/lda/main.c Thu Jan 20 19:21:20 2011 +0200 @@ -387,7 +387,7 @@ MAILBOX_FLAG_NO_INDEX_FILES); if (mailbox_open_stream(box, input) < 0) { i_fatal("Can't open delivery mail as raw: %s", - mail_storage_get_last_error(box->storage, &error)); + mailbox_get_last_error(box, &error)); } i_stream_unref(&input); } else { @@ -396,12 +396,12 @@ MAILBOX_FLAG_NO_INDEX_FILES); if (mailbox_open(box) < 0) { i_fatal("Can't open delivery mail as raw: %s", - mail_storage_get_last_error(box->storage, &error)); + mailbox_get_last_error(box, &error)); } } if (mailbox_sync(box, 0) < 0) { i_fatal("Can't sync delivery mail: %s", - mail_storage_get_last_error(box->storage, &error)); + mailbox_get_last_error(box, &error)); } raw_box = (struct raw_mailbox *)box; raw_box->envelope_sender = ctx.src_envelope_sender != NULL ? diff -r 8dbcf27f7c08 -r b748c622e896 src/lib-lda/mail-deliver.c --- a/src/lib-lda/mail-deliver.c Thu Jan 20 18:17:22 2011 +0200 +++ b/src/lib-lda/mail-deliver.c Thu Jan 20 19:21:20 2011 +0200 @@ -131,7 +131,6 @@ enum mail_error *error_r, const char **error_str_r) { struct mail_namespace *ns; - struct mail_storage *storage; struct mailbox *box; enum mailbox_flags flags = MAILBOX_FLAG_KEEP_RECENT | MAILBOX_FLAG_SAVEONLY | @@ -166,14 +165,13 @@ if (mailbox_open(box) == 0) return 0; - storage = mailbox_get_storage(box); - *error_str_r = mail_storage_get_last_error(storage, error_r); + *error_str_r = mailbox_get_last_error(box, error_r); if (!ctx->lda_mailbox_autocreate || *error_r != MAIL_ERROR_NOTFOUND) return -1; /* try creating it. */ if (mailbox_create(box, NULL, FALSE) < 0) { - *error_str_r = mail_storage_get_last_error(storage, error_r); + *error_str_r = mailbox_get_last_error(box, error_r); if (*error_r != MAIL_ERROR_EXISTS) return -1; /* someone else just created it */ @@ -185,7 +183,7 @@ /* and try opening again */ if (mailbox_sync(box, 0) < 0) { - *error_str_r = mail_storage_get_last_error(storage, error_r); + *error_str_r = mailbox_get_last_error(box, error_r); return -1; } return 0; diff -r 8dbcf27f7c08 -r b748c622e896 src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c --- a/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Thu Jan 20 18:17:22 2011 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Thu Jan 20 19:21:20 2011 +0200 @@ -504,7 +504,7 @@ MAILBOX_FLAG_IGNORE_ACLS); i_assert(box->storage == &ctx->storage->storage.storage); if (dbox_mailbox_open(box) < 0) { - (void)mail_storage_get_last_error(box->storage, &error); + error = mailbox_get_last_mail_error(box); mailbox_free(&box); if (error == MAIL_ERROR_TEMP) return -1; @@ -649,7 +649,7 @@ if (dbox_mailbox_open(box) == 0) break; - (void)mail_storage_get_last_error(box->storage, &error); + error = mailbox_get_last_mail_error(box); if (error == MAIL_ERROR_NOTFOUND && !created) { /* mailbox doesn't exist currently? see if creating it helps. */ diff -r 8dbcf27f7c08 -r b748c622e896 src/lib-storage/index/maildir/maildir-storage.c --- a/src/lib-storage/index/maildir/maildir-storage.c Thu Jan 20 18:17:22 2011 +0200 +++ b/src/lib-storage/index/maildir/maildir-storage.c Thu Jan 20 19:21:20 2011 +0200 @@ -245,7 +245,7 @@ if (mkdir_verify(box->storage, box->list->ns, path, perm->dir_create_mode, perm->file_create_gid, perm->file_create_gid_origin, verify) < 0) { - (void)mail_storage_get_last_error(box->storage, &error); + error = mailbox_get_last_mail_error(box); if (error != MAIL_ERROR_EXISTS) return -1; /* try to create all of the directories in case one diff -r 8dbcf27f7c08 -r b748c622e896 src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Thu Jan 20 18:17:22 2011 +0200 +++ b/src/lib-storage/mail-storage.c Thu Jan 20 19:21:20 2011 +0200 @@ -522,6 +522,20 @@ return storage->error_string; } +const char *mailbox_get_last_error(struct mailbox *box, + enum mail_error *error_r) +{ + return mail_storage_get_last_error(box->storage, error_r); +} + +enum mail_error mailbox_get_last_mail_error(struct mailbox *box) +{ + enum mail_error error; + + (void)mail_storage_get_last_error(box->storage, &error); + return error; +} + bool mail_storage_is_mailbox_file(struct mail_storage *storage) { return (storage->class_flags & @@ -616,7 +630,7 @@ if (ret < 0 && !box->storage->user->inbox_open_error_logged) { box->storage->user->inbox_open_error_logged = TRUE; i_error("Opening INBOX failed: %s", - mail_storage_get_last_error(box->storage, NULL)); + mailbox_get_last_error(box, NULL)); } } T_END; @@ -763,7 +777,6 @@ int mailbox_delete(struct mailbox *box) { - enum mail_error error; int ret; if (*box->name == '\0') { @@ -779,8 +792,7 @@ box->deleting = TRUE; if (mailbox_open(box) < 0) { - (void)mail_storage_get_last_error(box->storage, &error); - if (error != MAIL_ERROR_NOTFOUND) + if (mailbox_get_last_mail_error(box) != MAIL_ERROR_NOTFOUND) return -1; if (!box->mailbox_deleted) { /* \noselect mailbox */ @@ -990,7 +1002,7 @@ ret = box->v.sync_deinit(ctx, status_r); if (ret < 0 && box->inbox_user && !box->storage->user->inbox_open_error_logged) { - errormsg = mail_storage_get_last_error(box->storage, &error); + errormsg = mailbox_get_last_error(box, &error); if (error == MAIL_ERROR_NOTPOSSIBLE) { box->storage->user->inbox_open_error_logged = TRUE; i_error("Syncing INBOX failed: %s", errormsg); diff -r 8dbcf27f7c08 -r b748c622e896 src/lib-storage/mail-storage.h --- a/src/lib-storage/mail-storage.h Thu Jan 20 18:17:22 2011 +0200 +++ b/src/lib-storage/mail-storage.h Thu Jan 20 19:21:20 2011 +0200 @@ -329,6 +329,11 @@ /* Returns the error message of last occurred error. */ const char *mail_storage_get_last_error(struct mail_storage *storage, enum mail_error *error_r); +/* Wrapper for mail_storage_get_last_error(); */ +const char *mailbox_get_last_error(struct mailbox *box, + enum mail_error *error_r); +/* Wrapper for mail_storage_get_last_error(); */ +enum mail_error mailbox_get_last_mail_error(struct mailbox *box); /* Returns TRUE if mailboxes are files. */ bool mail_storage_is_mailbox_file(struct mail_storage *storage) ATTR_PURE; diff -r 8dbcf27f7c08 -r b748c622e896 src/lmtp/commands.c --- a/src/lmtp/commands.c Thu Jan 20 18:17:22 2011 +0200 +++ b/src/lmtp/commands.c Thu Jan 20 19:21:20 2011 +0200 @@ -596,7 +596,7 @@ if (mailbox_open_stream(box, input) < 0 || mailbox_sync(box, 0) < 0) { i_error("Can't open delivery mail as raw: %s", - mail_storage_get_last_error(box->storage, &error)); + mailbox_get_last_error(box, &error)); mailbox_free(&box); client_rcpt_fail_all(client); return -1; diff -r 8dbcf27f7c08 -r b748c622e896 src/plugins/autocreate/autocreate-plugin.c --- a/src/plugins/autocreate/autocreate-plugin.c Thu Jan 20 18:17:22 2011 +0200 +++ b/src/plugins/autocreate/autocreate-plugin.c Thu Jan 20 19:21:20 2011 +0200 @@ -27,8 +27,7 @@ box = mailbox_alloc(ns->list, name, 0); if (mailbox_create(box, NULL, FALSE) < 0) { - str = mail_storage_get_last_error(mailbox_get_storage(box), - &error); + str = mailbox_get_last_error(box, &error); if (error != MAIL_ERROR_EXISTS && ns->mail_set->mail_debug) { i_debug("autocreate: Failed to create mailbox %s: %s", name, str); diff -r 8dbcf27f7c08 -r b748c622e896 src/plugins/lazy-expunge/lazy-expunge-plugin.c --- a/src/plugins/lazy-expunge/lazy-expunge-plugin.c Thu Jan 20 18:17:22 2011 +0200 +++ b/src/plugins/lazy-expunge/lazy-expunge-plugin.c Thu Jan 20 19:21:20 2011 +0200 @@ -83,8 +83,7 @@ return box; } - *error_r = mail_storage_get_last_error(mailbox_get_storage(box), - &error); + *error_r = mailbox_get_last_error(box, &error); if (error != MAIL_ERROR_NOTFOUND) { mailbox_free(&box); return NULL; @@ -93,8 +92,7 @@ /* try creating and re-opening it. */ if (mailbox_create(box, NULL, FALSE) < 0 || mailbox_open(box) < 0) { - *error_r = mail_storage_get_last_error(mailbox_get_storage(box), - NULL); + *error_r = mailbox_get_last_error(box, NULL); mailbox_free(&box); return NULL; } @@ -263,7 +261,7 @@ break; mailbox_free(&dest_box); - mail_storage_get_last_error(src_box->storage, &error); + error = mailbox_get_last_mail_error(src_box); switch (error) { case MAIL_ERROR_EXISTS: break; @@ -292,12 +290,11 @@ struct mail_save_context *save_ctx; struct mail *mail; const char *errstr; - enum mail_error error; int ret; dest_box = mailbox_alloc(src_box->list, dest_name, 0); if (mailbox_open(dest_box) < 0) { - errstr = mail_storage_get_last_error(dest_box->storage, &error); + errstr = mailbox_get_last_error(dest_box, NULL); i_error("lazy_expunge: Couldn't open DELETE dest mailbox " "%s: %s", dest_name, errstr); mailbox_free(&dest_box); @@ -366,7 +363,6 @@ struct mail_namespace *expunge_ns, *dest_ns; struct mailbox *expunge_box; const char *destname, *str; - enum mail_error error; struct tm *tm; char timestamp[256]; int ret; @@ -412,7 +408,7 @@ since it's not really deleted in the lazy-expunge namespace, we might want to change it again. so mark the index undeleted. */ if (mailbox_open(expunge_box) < 0) { - str = mail_storage_get_last_error(expunge_box->storage, &error); + str = mailbox_get_last_error(expunge_box, NULL); i_error("lazy_expunge: Couldn't open DELETEd mailbox " "%s: %s", expunge_box->name, str); mailbox_free(&expunge_box); diff -r 8dbcf27f7c08 -r b748c622e896 src/plugins/quota/quota-count.c --- a/src/plugins/quota/quota-count.c Thu Jan 20 18:17:22 2011 +0200 +++ b/src/plugins/quota/quota-count.c Thu Jan 20 19:21:20 2011 +0200 @@ -33,7 +33,7 @@ box = mailbox_alloc(ns->list, storage_name, MAILBOX_FLAG_READONLY | MAILBOX_FLAG_KEEP_RECENT); if (mailbox_sync(box, MAILBOX_SYNC_FLAG_FULL_READ) < 0) { - mail_storage_get_last_error(mailbox_get_storage(box), &error); + error = mailbox_get_last_mail_error(box); mailbox_free(&box); if (error == MAIL_ERROR_TEMP) return -1; diff -r 8dbcf27f7c08 -r b748c622e896 src/plugins/snarf/snarf-plugin.c --- a/src/plugins/snarf/snarf-plugin.c Thu Jan 20 18:17:22 2011 +0200 +++ b/src/plugins/snarf/snarf-plugin.c Thu Jan 20 19:21:20 2011 +0200 @@ -62,8 +62,7 @@ save_ctx = mailbox_save_alloc(dest_trans); if (mailbox_copy(&save_ctx, mail) < 0 && !mail->expunged) { - (void)mail_storage_get_last_error(destbox->storage, - &error); + error = mailbox_get_last_mail_error(destbox); /* if we failed because of out of disk space, just move those messages we managed to move so far. */ if (error != MAIL_ERROR_NOSPACE) diff -r 8dbcf27f7c08 -r b748c622e896 src/plugins/virtual/virtual-storage.c --- a/src/plugins/virtual/virtual-storage.c Thu Jan 20 18:17:22 2011 +0200 +++ b/src/plugins/virtual/virtual-storage.c Thu Jan 20 19:21:20 2011 +0200 @@ -59,7 +59,7 @@ enum mail_error error; name = get_user_visible_mailbox_name(src); - str = mail_storage_get_last_error(src->storage, &error); + str = mailbox_get_last_error(src, &error); str = t_strdup_printf("%s (for backend mailbox %s)", str, name); mail_storage_set_error(dest->storage, error, str); @@ -139,8 +139,7 @@ enum mail_error error; const char *str, *name; - str = mail_storage_get_last_error(mailbox_get_storage(bbox->box), - &error); + str = mailbox_get_last_error(bbox->box, &error); name = t_strdup(get_user_visible_mailbox_name(bbox->box)); mailbox_free(&bbox->box); if (error == MAIL_ERROR_NOTFOUND) { diff -r 8dbcf27f7c08 -r b748c622e896 src/pop3/pop3-client.c --- a/src/pop3/pop3-client.c Thu Jan 20 18:17:22 2011 +0200 +++ b/src/pop3/pop3-client.c Thu Jan 20 19:21:20 2011 +0200 @@ -67,7 +67,6 @@ static int pop3_mail_get_size(struct client *client, struct mail *mail, uoff_t *size_r) { - struct mail_storage *storage; enum mail_error error; int ret; @@ -81,8 +80,7 @@ if (ret == 0) return 0; - storage = mailbox_get_storage(mail->box); - (void)mail_storage_get_last_error(storage, &error); + (void)mailbox_get_last_error(mail->box, &error); if (error != MAIL_ERROR_NOTPOSSIBLE) return -1; @@ -94,7 +92,7 @@ if (ret == 0) return 0; - (void)mail_storage_get_last_error(storage, &error); + (void)mailbox_get_last_error(mail->box, &error); if (error != MAIL_ERROR_NOTPOSSIBLE) return -1; @@ -187,11 +185,7 @@ } if (ret < 0) { - struct mail_storage *storage; - enum mail_error error; - - storage = mailbox_get_storage(client->mailbox); - *error_r = mail_storage_get_last_error(storage, &error); + *error_r = mailbox_get_last_error(client->mailbox, NULL); client_send_storage_error(client); } else { if (failed_uid == last_failed_uid && failed_uid != 0) { @@ -293,8 +287,8 @@ storage = mailbox_get_storage(client->mailbox); if (mailbox_open(client->mailbox) < 0) { errmsg = t_strdup_printf("Couldn't open INBOX: %s", - mail_storage_get_last_error(storage, - &error)); + mailbox_get_last_error(client->mailbox, + &error)); i_error("%s", errmsg); client_send_line(client, "-ERR [IN-USE] %s", errmsg); client_destroy(client, "Couldn't open INBOX"); @@ -555,9 +549,6 @@ void client_send_storage_error(struct client *client) { - struct mail_storage *storage; - enum mail_error error; - if (mailbox_is_inconsistent(client->mailbox)) { client_send_line(client, "-ERR Mailbox is in inconsistent " "state, please relogin."); @@ -565,9 +556,8 @@ return; } - storage = mailbox_get_storage(client->mailbox); client_send_line(client, "-ERR %s", - mail_storage_get_last_error(storage, &error)); + mailbox_get_last_error(client->mailbox, NULL)); } bool client_handle_input(struct client *client)