[Dovecot] There is a way to know if a email has been expunged ?
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 ?
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.
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@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.
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@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.
Tks timo !
I will see the plugin to do like it! Em 12/02/2012 13:46, "Timo Sirainen" tss@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@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.
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@gmail.com escreveu:
Tks timo !
I will see the plugin to do like it!
Em 12/02/2012 13:46, "Timo Sirainen" tss@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@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.
On 13.2.2012, at 19.28, Alex Baule wrote:
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 above is an "old way" to do it. It doesn't work well if you have any other plugins loaded.
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 ??
Never called at all? What storage backend are you using as the base? Maildir?
Anyway, the way you should be calling it is the exact same way quota plugin does:
void Mplugin_mailbox_allocated(struct mailbox *box) { struct mailbox_vfuncs *v = box->vlast; union mailbox_module_context *zbox;
zbox = p_new(box->pool, union mailbox_module_context, 1);
zbox->super = *v;
box->vlast = &zbox->super;
v->open = Mplugin_mailbox_open;
v->sync_notify = Mplugin_mailbox_sync_notify;
MODULE_CONTEXT_SET_SELF(box, Mplugin_storage_module, zbox);
}
hi Timo, now its works.. i do in the old way, my dovecot is 2.0.15.
You say it "old way", when it's change ? in dovecot 2.0.18 is in the old or new way ?
I asking because if i update dovecot, i need to update the plugin.
Tks !
Em 13 de fevereiro de 2012 18:18, Timo Sirainen tss@iki.fi escreveu:
On 13.2.2012, at 19.28, Alex Baule wrote:
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 above is an "old way" to do it. It doesn't work well if you have any other plugins loaded.
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 ??
Never called at all? What storage backend are you using as the base? Maildir?
Anyway, the way you should be calling it is the exact same way quota plugin does:
void Mplugin_mailbox_allocated(struct mailbox *box) { struct mailbox_vfuncs *v = box->vlast; union mailbox_module_context *zbox;
zbox = p_new(box->pool, union mailbox_module_context, 1); zbox->super = *v; box->vlast = &zbox->super;
v->open = Mplugin_mailbox_open; v->sync_notify = Mplugin_mailbox_sync_notify; MODULE_CONTEXT_SET_SELF(box, Mplugin_storage_module, zbox); }
On 16.2.2012, at 19.12, Alex Baule wrote:
hi Timo, now its works.. i do in the old way, my dovecot is 2.0.15.
You say it "old way", when it's change ? in dovecot 2.0.18 is in the old or new way ?
It changed before v2.0.0 release, so you should use the new way.
I asking because if i update dovecot, i need to update the plugin.
It works the same in v2.1.
participants (2)
-
Alex Baule
-
Timo Sirainen