]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
quota: Previous dict quota fix broke trash plugin.
authorTimo Sirainen <tss@iki.fi>
Sat, 18 Oct 2008 11:54:06 +0000 (14:54 +0300)
committerTimo Sirainen <tss@iki.fi>
Sat, 18 Oct 2008 11:54:06 +0000 (14:54 +0300)
--HG--
branch : HEAD

src/plugins/quota/quota-storage.c

index a56692b68e27a561939578dabd91c89ab067f4ff..d4723646d876e0f4a8a126ed89c7484b7b961f15 100644 (file)
@@ -254,20 +254,24 @@ static int quota_save_finish(struct mail_save_context *ctx)
        return quota_check(ctx->transaction, ctx->dest_mail);
 }
 
-static void quota_mailbox_sync_finish(struct quota_mailbox *qbox)
+static void quota_mailbox_sync_cleanup(struct quota_mailbox *qbox)
 {
        if (array_is_created(&qbox->expunge_uids)) {
                array_clear(&qbox->expunge_uids);
                array_clear(&qbox->expunge_sizes);
        }
 
-       if (qbox->expunge_qt != NULL) {
-               if (qbox->expunge_qt->tmp_mail != NULL) {
-                       mail_free(&qbox->expunge_qt->tmp_mail);
-                       mailbox_transaction_rollback(&qbox->expunge_trans);
-               }
-               (void)quota_transaction_commit(&qbox->expunge_qt);
+       if (qbox->expunge_qt != NULL && qbox->expunge_qt->tmp_mail != NULL) {
+               mail_free(&qbox->expunge_qt->tmp_mail);
+               mailbox_transaction_rollback(&qbox->expunge_trans);
        }
+}
+
+static void quota_mailbox_sync_commit(struct quota_mailbox *qbox)
+{
+       quota_mailbox_sync_cleanup(qbox);
+       if (qbox->expunge_qt != NULL)
+               (void)quota_transaction_commit(&qbox->expunge_qt);
        qbox->recalculate = FALSE;
 }
 
@@ -283,8 +287,14 @@ static void quota_mailbox_sync_notify(struct mailbox *box, uint32_t uid,
        if (qbox->module_ctx.super.sync_notify != NULL)
                qbox->module_ctx.super.sync_notify(box, uid, sync_type);
 
-       if (sync_type != MAILBOX_SYNC_TYPE_EXPUNGE || qbox->recalculate)
+       if (sync_type != MAILBOX_SYNC_TYPE_EXPUNGE || qbox->recalculate) {
+               if (uid == 0) {
+                       /* free the transaction before view syncing begins,
+                          otherwise it'll crash. */
+                       quota_mailbox_sync_cleanup(qbox);
+               }
                return;
+       }
 
        /* we're in the middle of syncing the mailbox, so it's a bad idea to
           try and get the message sizes at this point. Rely on sizes that
@@ -338,7 +348,7 @@ static int quota_mailbox_sync_deinit(struct mailbox_sync_context *ctx,
        /* 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. */
-       quota_mailbox_sync_finish(qbox);
+       quota_mailbox_sync_commit(qbox);
        return ret;
 }