From 2584e86cc2d8c31ba30a4109cf4ba09d1e37e28a Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Wed, 16 Dec 2009 19:27:57 -0500 Subject: [PATCH] lib-storage: Changed mailbox_sync() and mailbox_sync_deinit() APIs. Although we're already in beta stage, this is simple enough of a change that it shouldn't matter much. Having syncing also return status information made the API ugly and the status information wasn't even wanted all that often. --HG-- branch : HEAD --- src/doveadm/doveadm-mail.c | 2 +- src/dsync/dsync-worker-local.c | 7 +++--- src/imap/cmd-close.c | 2 +- src/imap/cmd-select.c | 10 ++++---- src/imap/imap-status.c | 7 ++++-- src/imap/imap-sync.c | 21 +++++++++------- src/lda/main.c | 2 +- src/lib-lda/mail-deliver.c | 5 ++-- src/lib-storage/index/index-storage.h | 3 +-- src/lib-storage/index/index-sync.c | 7 ++---- .../list/index-mailbox-list-sync.c | 24 +++++++------------ src/lib-storage/mail-storage-private.h | 3 +-- src/lib-storage/mail-storage.c | 14 +++++------ src/lib-storage/mail-storage.h | 13 +++++----- src/lib-storage/test-mailbox.c | 6 ++--- src/lmtp/commands.c | 3 +-- src/plugins/expire/expire-tool.c | 2 +- .../lazy-expunge/lazy-expunge-plugin.c | 2 +- src/plugins/mbox-snarf/mbox-snarf-plugin.c | 4 ++-- src/plugins/quota/quota-count.c | 2 +- src/plugins/quota/quota-storage.c | 7 +++--- src/plugins/trash/trash-plugin.c | 2 +- src/plugins/virtual/virtual-sync.c | 7 +++--- src/pop3/pop3-client.c | 5 ++-- src/pop3/pop3-commands.c | 3 +-- 25 files changed, 77 insertions(+), 86 deletions(-) diff --git a/src/doveadm/doveadm-mail.c b/src/doveadm/doveadm-mail.c index 52df88a6e5..cda1a9dc18 100644 --- a/src/doveadm/doveadm-mail.c +++ b/src/doveadm/doveadm-mail.c @@ -68,7 +68,7 @@ static void cmd_force_resync(struct mail_user *user, const char *args[]) box = mailbox_find_and_open(user, mailbox); storage = mailbox_get_storage(box); if (mailbox_sync(box, MAILBOX_SYNC_FLAG_FORCE_RESYNC | - MAILBOX_SYNC_FLAG_FIX_INCONSISTENT, 0, NULL) < 0) { + MAILBOX_SYNC_FLAG_FIX_INCONSISTENT) < 0) { i_fatal("Forcing a resync on mailbox %s failed: %s", mailbox, mail_storage_get_last_error(storage, NULL)); } diff --git a/src/dsync/dsync-worker-local.c b/src/dsync/dsync-worker-local.c index bd1bc8009c..54a1f26053 100644 --- a/src/dsync/dsync-worker-local.c +++ b/src/dsync/dsync-worker-local.c @@ -459,7 +459,7 @@ local_worker_mailbox_iter_next(struct dsync_worker_mailbox_iter *_iter, } box = mailbox_alloc(info->ns->list, storage_name, NULL, flags); - if (mailbox_sync(box, 0, 0, NULL) < 0) { + if (mailbox_sync(box, 0) < 0) { struct mail_storage *storage = mailbox_get_storage(box); i_error("Failed to sync mailbox %s: %s", info->name, @@ -653,7 +653,7 @@ static int local_mailbox_open(struct local_dsync_worker *worker, } box = mailbox_alloc(lbox->ns->list, lbox->storage_name, NULL, flags); - if (mailbox_sync(box, 0, 0, NULL) < 0) { + if (mailbox_sync(box, 0) < 0) { struct mail_storage *storage = mailbox_get_storage(box); i_error("Failed to sync mailbox %s: %s", lbox->storage_name, @@ -1148,8 +1148,7 @@ static void local_worker_mailbox_close(struct local_dsync_worker *worker) array_clear(&worker->saved_uids); if (mailbox_transaction_commit(&trans) < 0 || - mailbox_sync(worker->selected_box, - MAILBOX_SYNC_FLAG_FULL_WRITE, 0, NULL) < 0) + mailbox_sync(worker->selected_box, MAILBOX_SYNC_FLAG_FULL_WRITE) < 0) dsync_worker_set_failure(&worker->worker); mailbox_close(&worker->selected_box); diff --git a/src/imap/cmd-close.c b/src/imap/cmd-close.c index ab61079f63..d2ba879486 100644 --- a/src/imap/cmd-close.c +++ b/src/imap/cmd-close.c @@ -20,7 +20,7 @@ bool cmd_close(struct client_command_context *cmd) storage = mailbox_get_storage(mailbox); if ((ret = imap_expunge(mailbox, NULL)) < 0) client_send_untagged_storage_error(client, storage); - if (mailbox_sync(mailbox, 0, 0, NULL) < 0) + if (mailbox_sync(mailbox, 0) < 0) client_send_untagged_storage_error(client, storage); mailbox_close(&mailbox); diff --git a/src/imap/cmd-select.c b/src/imap/cmd-select.c index 35968a82a8..5455902fc9 100644 --- a/src/imap/cmd-select.c +++ b/src/imap/cmd-select.c @@ -277,15 +277,15 @@ select_open(struct imap_select_context *ctx, const char *mailbox, bool readonly) if (client->enabled_features != 0) mailbox_enable(ctx->box, client->enabled_features); - if (mailbox_sync(ctx->box, MAILBOX_SYNC_FLAG_FULL_READ, - STATUS_MESSAGES | STATUS_RECENT | - STATUS_FIRST_UNSEEN_SEQ | STATUS_UIDVALIDITY | - STATUS_UIDNEXT | STATUS_KEYWORDS | - STATUS_HIGHESTMODSEQ, &status) < 0) { + if (mailbox_sync(ctx->box, MAILBOX_SYNC_FLAG_FULL_READ) < 0) { client_send_storage_error(ctx->cmd, mailbox_get_storage(ctx->box)); return -1; } + mailbox_get_status(ctx->box, STATUS_MESSAGES | STATUS_RECENT | + STATUS_FIRST_UNSEEN_SEQ | STATUS_UIDVALIDITY | + STATUS_UIDNEXT | STATUS_KEYWORDS | + STATUS_HIGHESTMODSEQ, &status); client->mailbox = ctx->box; client->select_counter++; diff --git a/src/imap/imap-status.c b/src/imap/imap-status.c index 285c20d70c..b610f7dbe1 100644 --- a/src/imap/imap-status.c +++ b/src/imap/imap-status.c @@ -75,9 +75,12 @@ int imap_status_get(struct client_command_context *cmd, if (client->enabled_features != 0) mailbox_enable(box, client->enabled_features); - ret = mailbox_sync(box, 0, items, status_r); - if (ret < 0) { + ret = mailbox_sync(box, 0); + if (ret == 0) + mailbox_get_status(box, items, status_r); + else { struct mail_storage *storage = mailbox_get_storage(box); + *error_r = mail_storage_get_last_error(storage, &error); *error_r = imap_get_error_string(cmd, *error_r, error); } diff --git a/src/imap/imap-sync.c b/src/imap/imap-sync.c index 2bded00113..7588e90441 100644 --- a/src/imap/imap-sync.c +++ b/src/imap/imap-sync.c @@ -162,18 +162,19 @@ imap_sync_init(struct client *client, struct mailbox *box, static void imap_sync_send_highestmodseq(struct imap_sync_context *ctx, const struct mailbox_status *status, + const struct mailbox_sync_status *sync_status, struct client_command_context *sync_cmd) { struct client *client = ctx->client; uint64_t send_modseq = 0; - if (status->sync_delayed_expunges && + if (sync_status->sync_delayed_expunges && client->highest_fetch_modseq > client->sync_last_full_modseq) { /* if client updates highest-modseq using returned MODSEQs it loses expunges. try to avoid this by sending it a lower pre-expunge HIGHESTMODSEQ reply. */ send_modseq = client->sync_last_full_modseq; - } else if (!status->sync_delayed_expunges && + } else if (!sync_status->sync_delayed_expunges && status->highest_modseq > client->sync_last_full_modseq && status->highest_modseq > client->highest_fetch_modseq) { /* we've probably sent some VANISHED or EXISTS replies which @@ -199,7 +200,7 @@ imap_sync_send_highestmodseq(struct imap_sync_context *ctx, (unsigned long long)send_modseq)); } - if (!status->sync_delayed_expunges) { + if (!sync_status->sync_delayed_expunges) { /* no delayed expunges, remember this for future */ client->sync_last_full_modseq = status->highest_modseq; } @@ -211,21 +212,23 @@ int imap_sync_deinit(struct imap_sync_context *ctx, { struct client *client = ctx->client; struct mailbox_status status; + struct mailbox_sync_status sync_status; int ret; mail_free(&ctx->mail); if (array_is_created(&ctx->expunges)) array_free(&ctx->expunges); - if (mailbox_sync_deinit(&ctx->sync_ctx, STATUS_UIDVALIDITY | - STATUS_MESSAGES | STATUS_RECENT | - STATUS_HIGHESTMODSEQ, &status) < 0 || + if (mailbox_sync_deinit(&ctx->sync_ctx, &sync_status) < 0 || ctx->failed) { mailbox_transaction_rollback(&ctx->t); array_free(&ctx->tmp_keywords); i_free(ctx); return -1; } + mailbox_get_status(ctx->box, STATUS_UIDVALIDITY | + STATUS_MESSAGES | STATUS_RECENT | + STATUS_HIGHESTMODSEQ, &status); ret = mailbox_transaction_commit(&ctx->t); @@ -253,8 +256,10 @@ int imap_sync_deinit(struct imap_sync_context *ctx, now it contains added/removed messages. */ imap_sync_send_search_updates(ctx); - if ((client->enabled_features & MAILBOX_FEATURE_QRESYNC) != 0) - imap_sync_send_highestmodseq(ctx, &status, sync_cmd); + if ((client->enabled_features & MAILBOX_FEATURE_QRESYNC) != 0) { + imap_sync_send_highestmodseq(ctx, &status, &sync_status, + sync_cmd); + } if (array_is_created(&ctx->search_removes)) { array_free(&ctx->search_removes); diff --git a/src/lda/main.c b/src/lda/main.c index 2c54a171ae..6984c5788e 100644 --- a/src/lda/main.c +++ b/src/lda/main.c @@ -416,7 +416,7 @@ int main(int argc, char *argv[]) i_fatal("Can't open delivery mail as raw: %s", mail_storage_get_last_error(box->storage, &error)); } - if (mailbox_sync(box, 0, 0, NULL) < 0) { + if (mailbox_sync(box, 0) < 0) { i_fatal("Can't sync delivery mail: %s", mail_storage_get_last_error(box->storage, &error)); } diff --git a/src/lib-lda/mail-deliver.c b/src/lib-lda/mail-deliver.c index 471a04dd38..b6d0eac87b 100644 --- a/src/lib-lda/mail-deliver.c +++ b/src/lib-lda/mail-deliver.c @@ -129,8 +129,7 @@ mailbox_open_or_create_synced(struct mail_deliver_context *ctx, } /* and try opening again */ - if (mailbox_open(box) < 0 || - mailbox_sync(box, 0, 0, NULL) < 0) { + if (mailbox_sync(box, 0) < 0) { *error_r = mail_storage_get_last_error(storage, &error); mailbox_close(&box); return NULL; @@ -212,7 +211,7 @@ int mail_deliver_save(struct mail_deliver_context *ctx, const char *mailbox, ctx->saved_mail = TRUE; mail_deliver_log(ctx, "saved mail to %s", mailbox_name); - if (ctx->save_dest_mail && mailbox_sync(box, 0, 0, NULL) == 0) { + if (ctx->save_dest_mail && mailbox_sync(box, 0) == 0) { range = array_idx(&changes.saved_uids, 0); i_assert(range[0].seq1 == range[0].seq2); diff --git a/src/lib-storage/index/index-storage.h b/src/lib-storage/index/index-storage.h index c7c2013dfa..75232a4b0b 100644 --- a/src/lib-storage/index/index-storage.h +++ b/src/lib-storage/index/index-storage.h @@ -122,8 +122,7 @@ index_mailbox_sync_init(struct mailbox *box, enum mailbox_sync_flags flags, bool index_mailbox_sync_next(struct mailbox_sync_context *ctx, struct mailbox_sync_rec *sync_rec_r); int index_mailbox_sync_deinit(struct mailbox_sync_context *ctx, - enum mailbox_status_items status_items, - struct mailbox_status *status_r); + struct mailbox_sync_status *status_r); int index_storage_sync(struct mailbox *box, enum mailbox_sync_flags flags); enum mailbox_sync_type index_sync_type_convert(enum mail_index_sync_type type); diff --git a/src/lib-storage/index/index-sync.c b/src/lib-storage/index/index-sync.c index acad07159c..a13a72bb15 100644 --- a/src/lib-storage/index/index-sync.c +++ b/src/lib-storage/index/index-sync.c @@ -298,8 +298,7 @@ index_mailbox_expunge_unseen_recent(struct index_mailbox_sync_context *ctx) } int index_mailbox_sync_deinit(struct mailbox_sync_context *_ctx, - enum mailbox_status_items status_items, - struct mailbox_status *status_r) + struct mailbox_sync_status *status_r) { struct index_mailbox_sync_context *ctx = (struct index_mailbox_sync_context *)_ctx; @@ -342,10 +341,8 @@ int index_mailbox_sync_deinit(struct mailbox_sync_context *_ctx, } } - if (ret == 0 && status_items != 0) { - mailbox_get_status(_ctx->box, status_items, status_r); + if (status_r != NULL) status_r->sync_delayed_expunges = delayed_expunges; - } index_sync_search_results_update(ctx); diff --git a/src/lib-storage/list/index-mailbox-list-sync.c b/src/lib-storage/list/index-mailbox-list-sync.c index c64cf4a483..33d229b64f 100644 --- a/src/lib-storage/list/index-mailbox-list-sync.c +++ b/src/lib-storage/list/index-mailbox-list-sync.c @@ -306,22 +306,18 @@ static bool index_list_sync_next(struct mailbox_sync_context *ctx, } static int index_list_sync_deinit(struct mailbox_sync_context *ctx, - enum mailbox_status_items status_items, - struct mailbox_status *status_r) + struct mailbox_sync_status *status_r) { struct mailbox *box = ctx->box; struct index_list_mailbox *ibox = INDEX_LIST_STORAGE_CONTEXT(box); struct index_mailbox_list *ilist; struct mail_index_view *view; - struct mailbox_status tmp_status, *status; + struct mailbox_status status; uint32_t uid, seq; if (!box->opened) { /* nothing synced. just return the status. */ i_free(ctx); - - if (status_items != 0) - index_list_get_status(box, status_items, status_r); return 0; } @@ -329,16 +325,10 @@ static int index_list_sync_deinit(struct mailbox_sync_context *ctx, if (ilist == NULL) { /* indexing disabled */ - return ibox->module_ctx.super. - sync_deinit(ctx, status_items, status_r); + return ibox->module_ctx.super.sync_deinit(ctx, status_r); } - /* if status_items == 0, the status_r may be NULL. we really want to - know the status anyway, so save it elsewhere then */ - status = status_items == 0 ? &tmp_status : status_r; - status_items |= CACHED_STATUS_ITEMS; - - if (ibox->module_ctx.super.sync_deinit(ctx, status_items, status) < 0) + if (ibox->module_ctx.super.sync_deinit(ctx, status_r) < 0) return -1; ctx = NULL; @@ -349,8 +339,10 @@ static int index_list_sync_deinit(struct mailbox_sync_context *ctx, } view = mail_index_view_open(ilist->mail_index); - if (mail_index_lookup_seq(view, uid, &seq)) - (void)index_list_update(ilist, box, view, seq, status); + if (mail_index_lookup_seq(view, uid, &seq)) { + mailbox_get_status(box, CACHED_STATUS_ITEMS, &status); + (void)index_list_update(ilist, box, view, seq, &status); + } mail_index_view_close(&view); return 0; } diff --git a/src/lib-storage/mail-storage-private.h b/src/lib-storage/mail-storage-private.h index b0ffd9bb84..bf2cc59935 100644 --- a/src/lib-storage/mail-storage-private.h +++ b/src/lib-storage/mail-storage-private.h @@ -116,8 +116,7 @@ struct mailbox_vfuncs { bool (*sync_next)(struct mailbox_sync_context *ctx, struct mailbox_sync_rec *sync_rec_r); int (*sync_deinit)(struct mailbox_sync_context *ctx, - enum mailbox_status_items status_items, - struct mailbox_status *status_r); + struct mailbox_sync_status *status_r); /* Called once for each expunge. Called one or more times for flag/keyword changes. Once the sync is finished, called with diff --git a/src/lib-storage/mail-storage.c b/src/lib-storage/mail-storage.c index b06369367c..778f36c6b6 100644 --- a/src/lib-storage/mail-storage.c +++ b/src/lib-storage/mail-storage.c @@ -616,20 +616,20 @@ bool mailbox_sync_next(struct mailbox_sync_context *ctx, } int mailbox_sync_deinit(struct mailbox_sync_context **_ctx, - enum mailbox_status_items status_items, - struct mailbox_status *status_r) + struct mailbox_sync_status *status_r) { struct mailbox_sync_context *ctx = *_ctx; *_ctx = NULL; - return ctx->box->v.sync_deinit(ctx, status_items, status_r); + + memset(status_r, 0, sizeof(*status_r)); + return ctx->box->v.sync_deinit(ctx, status_r); } -int mailbox_sync(struct mailbox *box, enum mailbox_sync_flags flags, - enum mailbox_status_items status_items, - struct mailbox_status *status_r) +int mailbox_sync(struct mailbox *box, enum mailbox_sync_flags flags) { struct mailbox_sync_context *ctx; + struct mailbox_sync_status status; if (array_count(&box->search_results) == 0) { /* we don't care about mailbox's current state, so we might @@ -638,7 +638,7 @@ int mailbox_sync(struct mailbox *box, enum mailbox_sync_flags flags, } ctx = mailbox_sync_init(box, flags); - return mailbox_sync_deinit(&ctx, status_items, status_r); + return mailbox_sync_deinit(&ctx, &status); } #undef mailbox_notify_changes diff --git a/src/lib-storage/mail-storage.h b/src/lib-storage/mail-storage.h index d517387003..715999a6b2 100644 --- a/src/lib-storage/mail-storage.h +++ b/src/lib-storage/mail-storage.h @@ -187,8 +187,6 @@ struct mailbox_status { /* Fields that have "temp" or "yes" caching decision. */ const ARRAY_TYPE(const_string) *cache_fields; - /* There are expunges that haven't been synced yet */ - unsigned int sync_delayed_expunges:1; /* Modseqs aren't permanent (index is in memory) */ unsigned int nonpermanent_modseqs:1; }; @@ -221,6 +219,10 @@ struct mailbox_sync_rec { uint32_t seq1, seq2; enum mailbox_sync_type type; }; +struct mailbox_sync_status { + /* There are expunges that haven't been synced yet */ + unsigned int sync_delayed_expunges:1; +}; struct mailbox_expunge_rec { /* IMAP UID */ @@ -381,13 +383,10 @@ mailbox_sync_init(struct mailbox *box, enum mailbox_sync_flags flags); bool mailbox_sync_next(struct mailbox_sync_context *ctx, struct mailbox_sync_rec *sync_rec_r); int mailbox_sync_deinit(struct mailbox_sync_context **ctx, - enum mailbox_status_items status_items, - struct mailbox_status *status_r); + struct mailbox_sync_status *status_r); /* One-step mailbox synchronization. Use this if you don't care about changes. */ -int mailbox_sync(struct mailbox *box, enum mailbox_sync_flags flags, - enum mailbox_status_items status_items, - struct mailbox_status *status_r); +int mailbox_sync(struct mailbox *box, enum mailbox_sync_flags flags); /* Call given callback function when something changes in the mailbox. */ void mailbox_notify_changes(struct mailbox *box, unsigned int min_interval, diff --git a/src/lib-storage/test-mailbox.c b/src/lib-storage/test-mailbox.c index feef2157d2..f0a4e33a57 100644 --- a/src/lib-storage/test-mailbox.c +++ b/src/lib-storage/test-mailbox.c @@ -81,10 +81,10 @@ test_mailbox_sync_next(struct mailbox_sync_context *ctx ATTR_UNUSED, static int test_mailbox_sync_deinit(struct mailbox_sync_context *ctx, - enum mailbox_status_items status_items, - struct mailbox_status *status_r) + struct mailbox_sync_status *status_r) { - test_mailbox_get_status(ctx->box, status_items, status_r); + if (status_r != NULL) + memset(status_r, 0, sizeof(*status_r)); i_free(ctx); return 0; } diff --git a/src/lmtp/commands.c b/src/lmtp/commands.c index eb1f6ce9ae..c3b841dbb3 100644 --- a/src/lmtp/commands.c +++ b/src/lmtp/commands.c @@ -572,8 +572,7 @@ static int client_open_raw_mail(struct client *client, struct istream *input) mailbox_alloc(client->raw_mail_user->namespaces->list, "Dovecot Delivery Mail", input, MAILBOX_FLAG_NO_INDEX_FILES); - if (mailbox_open(box) < 0 || - mailbox_sync(box, 0, 0, NULL) < 0) { + if (mailbox_sync(box, 0) < 0) { i_error("Can't open delivery mail as raw: %s", mail_storage_get_last_error(box->storage, &error)); mailbox_close(&box); diff --git a/src/plugins/expire/expire-tool.c b/src/plugins/expire/expire-tool.c index 79db1c3673..8b80b9be19 100644 --- a/src/plugins/expire/expire-tool.c +++ b/src/plugins/expire/expire-tool.c @@ -182,7 +182,7 @@ mailbox_delete_old_mails(struct expire_context *ctx, const char *user, mailbox_transaction_rollback(&t); } - if (mailbox_sync(box, MAILBOX_SYNC_FLAG_FAST, 0, NULL) < 0) + if (mailbox_sync(box, MAILBOX_SYNC_FLAG_FAST) < 0) ret = -1; mailbox_close(&box); diff --git a/src/plugins/lazy-expunge/lazy-expunge-plugin.c b/src/plugins/lazy-expunge/lazy-expunge-plugin.c index 900109f144..49a6d4e2be 100644 --- a/src/plugins/lazy-expunge/lazy-expunge-plugin.c +++ b/src/plugins/lazy-expunge/lazy-expunge-plugin.c @@ -133,7 +133,7 @@ static void lazy_expunge_mail_expunge(struct mail *_mail) lt->failed = TRUE; return; } - if (mailbox_sync(lt->dest_box, 0, 0, NULL) < 0) { + if (mailbox_sync(lt->dest_box, 0) < 0) { mail_storage_set_critical(_mail->box->storage, "lazy_expunge: Couldn't sync expunge mailbox"); mailbox_close(<->dest_box); diff --git a/src/plugins/mbox-snarf/mbox-snarf-plugin.c b/src/plugins/mbox-snarf/mbox-snarf-plugin.c index 578d3092fe..093c4aacd2 100644 --- a/src/plugins/mbox-snarf/mbox-snarf-plugin.c +++ b/src/plugins/mbox-snarf/mbox-snarf-plugin.c @@ -41,7 +41,7 @@ static int mbox_snarf(struct mailbox *srcbox, struct mailbox *destbox) enum mail_error error; int ret; - if (mailbox_sync(srcbox, MAILBOX_SYNC_FLAG_FULL_READ, 0, NULL) < 0) + if (mailbox_sync(srcbox, MAILBOX_SYNC_FLAG_FULL_READ) < 0) return -1; src_trans = mailbox_transaction_begin(srcbox, 0); @@ -92,7 +92,7 @@ static int mbox_snarf(struct mailbox *srcbox, struct mailbox *destbox) ret = -1; } if (ret == 0) { - if (mailbox_sync(srcbox, 0, 0, NULL) < 0) + if (mailbox_sync(srcbox, 0) < 0) ret = -1; } return ret; diff --git a/src/plugins/quota/quota-count.c b/src/plugins/quota/quota-count.c index cf01fdb16f..42b4f92eac 100644 --- a/src/plugins/quota/quota-count.c +++ b/src/plugins/quota/quota-count.c @@ -38,7 +38,7 @@ quota_count_mailbox(struct quota_root *root, struct mail_namespace *ns, return 0; } - if (mailbox_sync(box, MAILBOX_SYNC_FLAG_FULL_READ, 0, NULL) < 0) { + if (mailbox_sync(box, MAILBOX_SYNC_FLAG_FULL_READ) < 0) { mailbox_close(&box); return -1; } diff --git a/src/plugins/quota/quota-storage.c b/src/plugins/quota/quota-storage.c index 0c63de15b7..a7b2d49750 100644 --- a/src/plugins/quota/quota-storage.c +++ b/src/plugins/quota/quota-storage.c @@ -318,13 +318,12 @@ static void quota_mailbox_sync_notify(struct mailbox *box, uint32_t uid, } static int quota_mailbox_sync_deinit(struct mailbox_sync_context *ctx, - enum mailbox_status_items status_items, - struct mailbox_status *status_r) + struct mailbox_sync_status *status_r) { struct quota_mailbox *qbox = QUOTA_CONTEXT(ctx->box); int ret; - ret = qbox->module_ctx.super.sync_deinit(ctx, status_items, status_r); + ret = qbox->module_ctx.super.sync_deinit(ctx, status_r); /* update quota only after syncing is finished. the quota commit may recalculate the quota and cause all mailboxes to be synced, including the one we're already syncing. */ @@ -386,7 +385,7 @@ quota_mailbox_delete_shrink_quota(struct mailbox *box) struct mail_search_args *search_args; int ret; - if (mailbox_sync(box, MAILBOX_SYNC_FLAG_FULL_READ, 0, NULL) < 0) + if (mailbox_sync(box, MAILBOX_SYNC_FLAG_FULL_READ) < 0) return -1; t = mailbox_transaction_begin(box, 0); diff --git a/src/plugins/trash/trash-plugin.c b/src/plugins/trash/trash-plugin.c index e4380ecbda..964dd29b71 100644 --- a/src/plugins/trash/trash-plugin.c +++ b/src/plugins/trash/trash-plugin.c @@ -59,7 +59,7 @@ static int trash_clean_mailbox_open(struct trash_mailbox *trash) return 0; } - if (mailbox_sync(trash->box, MAILBOX_SYNC_FLAG_FULL_READ, 0, NULL) < 0) + if (mailbox_sync(trash->box, MAILBOX_SYNC_FLAG_FULL_READ) < 0) return -1; trash->trans = mailbox_transaction_begin(trash->box, 0); diff --git a/src/plugins/virtual/virtual-sync.c b/src/plugins/virtual/virtual-sync.c index 98efe0a206..fe1c1321e3 100644 --- a/src/plugins/virtual/virtual-sync.c +++ b/src/plugins/virtual/virtual-sync.c @@ -935,6 +935,7 @@ static int virtual_sync_backend_box_sync(struct virtual_sync_context *ctx, struct mailbox_sync_context *sync_ctx; const struct virtual_backend_uidmap *uidmap; struct mailbox_sync_rec sync_rec; + struct mailbox_sync_status sync_status; unsigned int idx1, idx2; uint32_t vseq, vuid; @@ -971,7 +972,7 @@ static int virtual_sync_backend_box_sync(struct virtual_sync_context *ctx, break; } } - return mailbox_sync_deinit(&sync_ctx, 0, NULL); + return mailbox_sync_deinit(&sync_ctx, &sync_status); } static void virtual_sync_backend_ext_header(struct virtual_sync_context *ctx, @@ -1043,10 +1044,10 @@ static int virtual_sync_backend_box(struct virtual_sync_context *ctx, /* first sync in this process */ i_assert(ctx->expunge_removed); - if (mailbox_sync(bbox->box, sync_flags, STATUS_UIDVALIDITY, - &status) < 0) + if (mailbox_sync(bbox->box, sync_flags) < 0) return -1; + mailbox_get_status(bbox->box, STATUS_UIDVALIDITY, &status); virtual_backend_box_sync_mail_set(bbox); if (status.uidvalidity != bbox->sync_uid_validity) { /* UID validity changed since last sync (or this is diff --git a/src/pop3/pop3-client.c b/src/pop3/pop3-client.c index b590bc5e48..ecbc3eaa21 100644 --- a/src/pop3/pop3-client.c +++ b/src/pop3/pop3-client.c @@ -84,11 +84,12 @@ static bool init_mailbox(struct client *client, const char **error_r) for (i = 0; i < 2; i++) { expunged = FALSE; - if (mailbox_sync(client->mailbox, MAILBOX_SYNC_FLAG_FULL_READ, - STATUS_UIDVALIDITY, &status) < 0) { + if (mailbox_sync(client->mailbox, + MAILBOX_SYNC_FLAG_FULL_READ) < 0) { client_send_storage_error(client); break; } + mailbox_get_status(client->mailbox, STATUS_UIDVALIDITY, &status); client->uid_validity = status.uidvalidity; t = mailbox_transaction_begin(client->mailbox, 0); diff --git a/src/pop3/pop3-commands.c b/src/pop3/pop3-commands.c index b6bbf6d1f0..056af71cb6 100644 --- a/src/pop3/pop3-commands.c +++ b/src/pop3/pop3-commands.c @@ -243,8 +243,7 @@ static int cmd_quit(struct client *client, const char *args ATTR_UNUSED) } if (mailbox_transaction_commit(&client->trans) < 0 || - mailbox_sync(client->mailbox, MAILBOX_SYNC_FLAG_FULL_WRITE, - 0, NULL) < 0) { + mailbox_sync(client->mailbox, MAILBOX_SYNC_FLAG_FULL_WRITE) < 0) { client_send_storage_error(client); client_disconnect(client, "Storage error during logout."); return 1; -- 2.47.3