[Dovecot] There is a way to know if a email has been expunged ?
Alex Baule
alexwbaule at gmail.com
Mon Feb 13 19:28:37 EET 2012
Hi Again Timo !
I Trying to port quota plugin notify_sync to my plugin, but i found some issues.
I have the hooks already, to replace the mailbx_allocated, like quota
plugin does.
static struct mail_storage_hooks emexis_mail_storage_hooks = {
.mail_user_created = Mplugin_mail_user_created,
.mailbox_allocated = Mplugin_mailbox_allocated,
.mail_allocated = Mplugin_mail_allocated,
.mailbox_list_created = Mplugin_mailbox_list_created,
.mail_namespaces_created = Mplugin_antispam_mail_namespaces_created
};
inside the Mplugin_mailbox_allocated, i have:
static void emexis_mailbox_allocated(struct mailbox *box)
{
union mailbox_module_context *zbox;
zbox = p_new(box->pool, union mailbox_module_context, 1);
zbox->super = box->v;
box->v.open = Mplugin_mailbox_open;
box->v.sync_notify = Mplugin_mailbox_sync_notify;
MODULE_CONTEXT_SET_SELF(box, emexis_storage_module, zbox);
}
The v.open i rewrite because my plugin needs.
I try to call the sync_notify like this:
box->v.sync_notify = Mplugin_mailbox_sync_notify;
and follow quota plugin, i try to to this too:
struct mailbox_vfuncs *v = box->vlast;
v->sync_notify = Mplugin_mailbox_sync_notify;
But in this two cases, the Mplugin_mailbox_sync_notify is never
called... i missing something ??
Tks !
Em 12 de fevereiro de 2012 14:48, Alex Baule <alexwbaule at gmail.com> escreveu:
> Tks timo !
>
> I will see the plugin to do like it!
>
> Em 12/02/2012 13:46, "Timo Sirainen" <tss at iki.fi> escreveu:
>
>> Hi,
>>
>> Yeah, you shouldn't do the erasing directly in expunge(), because it may
>> still be aborted. Do it in sync_notify() like quota plugin does.
>>
>> On 12.2.2012, at 16.52, Alex Baule wrote:
>>
>> > I want to know because i have header and body splited. To erase the
>> > body, i must have shure, that header was expunged. Some tests that i
>> > made, the client call expunge, but i don't know why (there is notting
>> > in mail log) the header was not expunged, nut my body was, because i
>> > call it before expunge the header. something like this.
>> >
>> > if (found_body){
>> > erase_body();
>> > super.expunge(_mail);
>> > }
>> >
>> > Because that expunge that no happen, (the client call, but the email
>> > was not expunged) i think to do like this way:
>> >
>> > if (found_body){
>> > super.expunge(_mail);
>> > if(_mail was expunged){
>> > erase_body();
>> > }
>> > }
>> >
>> > TKs Timo !
>> >
>> > Em 12 de fevereiro de 2012 02:19, Timo Sirainen <tss at iki.fi> escreveu:
>> >> On 10.2.2012, at 19.39, Alex Baule wrote:
>> >>
>> >>> Hy Everyone...and Timo !
>> >>>
>> >>> There is a way to know if a email was expunged (deleted from hard
>> >>> disk) inside a plugin ? I rewrite the expunge function, but the real
>> >>> expunge function is void, i can't know if was really expunged.
>> >>>
>> >>> There is a way to know this ?
>> >>
>> >> It's not known until transaction_commit() what messages are expunged.
>> >> What do you need to know this for? There are a few different ways.
>> >>
>> >> If you simply need one of the sessions to definitely know that it
>> >> expunged a message, you can do it like quota plugin does. (So even if there
>> >> are multiple clients doing EXPUNGE at the same time, quota is never
>> >> decreased more than once per mail.) See quota-storage.c and most importantly
>> >> quota_mailbox_sync_notify().
>> >>
>> >> Quota code also shows the other method of doing it: keep track of what
>> >> mail_expunge()s have been called, and then in transaction commit check if it
>> >> succeeds and if it does do what you want to do.
>> >>
>> >
>>
>
More information about the dovecot
mailing list