Mercurial > dovecot > core-2.2
comparison src/lib-storage/mail-storage.c @ 12264:a3e40c6b14fe
lib-storage: If mailbox deletion failed, we crashed while trying to write undelete record to index.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 14 Oct 2010 16:53:04 +0100 |
parents | ad81284d43ff |
children | 0cc916fc09f9 |
comparison
equal
deleted
inserted
replaced
12263:03ac8057710d | 12264:a3e40c6b14fe |
---|---|
667 return box->v.update(box, update); | 667 return box->v.update(box, update); |
668 } | 668 } |
669 | 669 |
670 int mailbox_mark_index_deleted(struct mailbox *box, bool del) | 670 int mailbox_mark_index_deleted(struct mailbox *box, bool del) |
671 { | 671 { |
672 struct mail_index_transaction *trans; | |
672 enum mail_index_transaction_flags trans_flags = 0; | 673 enum mail_index_transaction_flags trans_flags = 0; |
673 struct mail_index_transaction *trans; | 674 enum mailbox_flags old_flag; |
675 int ret; | |
674 | 676 |
675 if (box->marked_deleted && del) { | 677 if (box->marked_deleted && del) { |
676 /* we already marked it deleted. this allows plugins to | 678 /* we already marked it deleted. this allows plugins to |
677 "lock" the deletion earlier. */ | 679 "lock" the deletion earlier. */ |
678 return 0; | 680 return 0; |
679 } | 681 } |
682 | |
683 old_flag = box->flags & MAILBOX_FLAG_OPEN_DELETED; | |
684 box->flags |= MAILBOX_FLAG_OPEN_DELETED; | |
685 ret = mailbox_open(box); | |
686 box->flags = (box->flags & ~MAILBOX_FLAG_OPEN_DELETED) | old_flag; | |
687 if (ret < 0) | |
688 return -1; | |
680 | 689 |
681 trans_flags = del ? 0 : MAIL_INDEX_TRANSACTION_FLAG_EXTERNAL; | 690 trans_flags = del ? 0 : MAIL_INDEX_TRANSACTION_FLAG_EXTERNAL; |
682 trans = mail_index_transaction_begin(box->view, trans_flags); | 691 trans = mail_index_transaction_begin(box->view, trans_flags); |
683 if (del) | 692 if (del) |
684 mail_index_set_deleted(trans); | 693 mail_index_set_deleted(trans); |