index-expunge.c revision 74a02d35d21807b9f9069964514d8c09e3631ea4
45312f52ff3a3d4c137447be4c7556500c2f8bf2Timo Sirainen/* Copyright (C) 2002 Timo Sirainen */
ea5f188fc29dfaa0c4071e6413e16e1d04263722Timo Sirainenint index_expunge_seek_first(IndexMailbox *ibox, unsigned int *seq,
63a61b7a739ae0f3f520215137d9c50f94d0f34fTimo Sirainen i_assert(ibox->index->lock_type == MAIL_LOCK_EXCLUSIVE);
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen /* no deleted messages */
a0b0d629931773c17a236f6214adbe0e13b9b3fdTimo Sirainen /* find mails with DELETED flag and expunge them */
a0b0d629931773c17a236f6214adbe0e13b9b3fdTimo Sirainen *rec = hdr->first_deleted_uid_lowwater >= hdr->next_uid ? NULL :
a0b0d629931773c17a236f6214adbe0e13b9b3fdTimo Sirainen "index header's deleted_messages_count (%u) "
a0b0d629931773c17a236f6214adbe0e13b9b3fdTimo Sirainen "or first_deleted_uid_lowwater (%u) "
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen /* fsck should be enough to fix it */
af1f4b17a92ca7b2661737e65c7849df289d3070Timo Sirainen ibox->index->set_flags |= MAIL_INDEX_FLAG_FSCK;
f1901fd21906911f7be075c965ac882f6a87b4c3Timo Sirainen *seq = ibox->index->get_sequence(ibox->index, *rec);
fe6c1556d3529a6376d4cbb3766c34aebde0de99Timo Sirainen mail_storage_set_error(box->storage, "Mailbox is read-only");
73247459cf41eb1e5ae5bc61354db46d3b05ee75Timo Sirainen if (!ibox->index->set_lock(ibox->index, MAIL_LOCK_EXCLUSIVE))
fe6c1556d3529a6376d4cbb3766c34aebde0de99Timo Sirainen failed = !ibox->expunge_locked(ibox, NULL, NULL);