0
|
1 /* Copyright (C) 2002 Timo Sirainen */
|
|
2
|
|
3 #include "lib.h"
|
|
4 #include "mbox-storage.h"
|
|
5
|
|
6 int mbox_expunge_locked(IndexMailbox *ibox,
|
|
7 MailExpungeFunc expunge_func, void *user_data)
|
|
8 {
|
|
9 MailIndexRecord *rec;
|
|
10 unsigned int seq, uid;
|
|
11
|
|
12 /* FIXME: open the mbox file, lock it, and remove the deleted
|
|
13 blocks. probably better to do it in small blocks than to
|
|
14 memmove() megabytes of data.. */
|
|
15
|
|
16 rec = index_expunge_seek_first(ibox, &seq);
|
|
17 while (rec != NULL) {
|
|
18 if (rec->msg_flags & MAIL_DELETED) {
|
|
19 /* save UID before deletion */
|
|
20 uid = rec->uid;
|
|
21
|
|
22 if (!ibox->index->expunge(ibox->index, rec,
|
|
23 seq, FALSE))
|
|
24 return FALSE;
|
|
25
|
|
26 if (expunge_func != NULL)
|
|
27 expunge_func(&ibox->box, seq, uid, user_data);
|
|
28 seq--;
|
|
29 }
|
|
30 rec = ibox->index->next(ibox->index, rec);
|
|
31 seq++;
|
|
32 }
|
|
33
|
|
34 return TRUE;
|
|
35 }
|