]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Changed mailbox_sync() and mailbox_sync_deinit() APIs.
authorTimo Sirainen <tss@iki.fi>
Thu, 17 Dec 2009 00:27:57 +0000 (19:27 -0500)
committerTimo Sirainen <tss@iki.fi>
Thu, 17 Dec 2009 00:27:57 +0000 (19:27 -0500)
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

25 files changed:
src/doveadm/doveadm-mail.c
src/dsync/dsync-worker-local.c
src/imap/cmd-close.c
src/imap/cmd-select.c
src/imap/imap-status.c
src/imap/imap-sync.c
src/lda/main.c
src/lib-lda/mail-deliver.c
src/lib-storage/index/index-storage.h
src/lib-storage/index/index-sync.c
src/lib-storage/list/index-mailbox-list-sync.c
src/lib-storage/mail-storage-private.h
src/lib-storage/mail-storage.c
src/lib-storage/mail-storage.h
src/lib-storage/test-mailbox.c
src/lmtp/commands.c
src/plugins/expire/expire-tool.c
src/plugins/lazy-expunge/lazy-expunge-plugin.c
src/plugins/mbox-snarf/mbox-snarf-plugin.c
src/plugins/quota/quota-count.c
src/plugins/quota/quota-storage.c
src/plugins/trash/trash-plugin.c
src/plugins/virtual/virtual-sync.c
src/pop3/pop3-client.c
src/pop3/pop3-commands.c

index 52df88a6e5eea9365162d255b25a87218db2b850..cda1a9dc188e5bf3e16ba9037ccf52d690e2d219 100644 (file)
@@ -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));
        }
index bd1bc8009c1932d6a81c403488131500423134a8..54a1f260535b80ef961506b6f44d064bffa23586 100644 (file)
@@ -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);
index ab61079f6310de069eedc0626f6eff121663ea4d..d2ba879486181ce78f06a23cbe1171b18c7a3181 100644 (file)
@@ -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);
index 35968a82a843bef26be48236e5fb68c9ea5f541a..5455902fc9d440b35d7047c44343a574be733877 100644 (file)
@@ -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++;
index 285c20d70c5e041c1e3a0b43242e1bd23a5dbebb..b610f7dbe10ae63da2fa1b6f235c493995cdba4f 100644 (file)
@@ -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);
        }
index 2bded001138166d628cac60b048d780a704d50d8..7588e9044122ee596f040af216ffa0d3d9a81595 100644 (file)
@@ -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);
index 2c54a171aee07f60c452ddb5ff57fc4a9087ef5f..6984c5788e630823c3f17cb4a947913f3173608e 100644 (file)
@@ -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));
        }
index 471a04dd38d812c0a1aaf06cc8305f4735472f0e..b6d0eac87b2e2d3ae4f635b338d77a497369b509 100644 (file)
@@ -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);
 
index c7c2013dfa1a1c85631425b78f743326e68e28b0..75232a4b0b911169b727b44d0b6b6640e1cb3013 100644 (file)
@@ -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);
index acad07159c3784c4d11f976196110fac500a46f7..a13a72bb15765f5c90b13c584c2dddcc6ceae785 100644 (file)
@@ -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);
 
index c64cf4a483b580b8dd78dd27aed7a4c4a57f468a..33d229b64f3ac4960e9fd84880c189d5d03506d5 100644 (file)
@@ -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;
 }
index b0ffd9bb84f34e1825a205e2442f32915f6e8b93..bf2cc5993534f5b4ac01c1d0af64d710951f8a60 100644 (file)
@@ -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
index b06369367c94f73136e996b5bf68bf5d36a5715d..778f36c6b65f4fc6675cbd7d8da326d7703b5ac5 100644 (file)
@@ -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
index d51738700397d786df2c5f4ee530082387918468..715999a6b2a19d452ff4d70ccaeb9b6cea9ac557 100644 (file)
@@ -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,
index feef2157d22757b86931677c292dcbf070e08117..f0a4e33a5753df6b7288235229b69d56b643208c 100644 (file)
@@ -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;
 }
index eb1f6ce9ae90cd22e71bf51919609d8aee9764df..c3b841dbb399440e55fe4b6608da34e69eaad859 100644 (file)
@@ -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);
index 79db1c367382b00ac651b201de07a27b51951b74..8b80b9be19fc8c85007ed94909c507cda8cff826 100644 (file)
@@ -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);
index 900109f1446602800b46dc93bc37a00e8fdd13d4..49a6d4e2bedbda4ef053ca2bb846451763f59c80 100644 (file)
@@ -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(&lt->dest_box);
index 578d3092fe6a15d44157e140a478debf8d02031e..093c4aacd2169df13205ef00e3312b8a19277d51 100644 (file)
@@ -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;
index cf01fdb16f5357ca354b80a5b34bf212a0483930..42b4f92eac036d4ba0fc1c38d13b4c5a27766894 100644 (file)
@@ -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;
        }
index 0c63de15b7afb11d3147aef7beff1699ab0a4bcc..a7b2d49750aa18c2c4001fc69ed43af449334216 100644 (file)
@@ -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);
index e4380ecbdae53ccc6f68bfb61fb21d9647b92375..964dd29b71ad9abcca4f395d467df54b9fd4f084 100644 (file)
@@ -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);
index 98efe0a206fb7f98bff7df30f8530bc99aad79b1..fe1c1321e32ed57416883e052865b95b96b50415 100644 (file)
@@ -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
index b590bc5e484b77db62bb8c4a5d1f03f62dd227eb..ecbc3eaa21f052e73fb4b4ebd2569e6ca04025f6 100644 (file)
@@ -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);
index b6bbf6d1f06d1deb67fbff42e35de7b09ff93864..056af71cb6e887c219d0b2ac17f0ea7ca6232f95 100644 (file)
@@ -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;