dovecot-1.1: If first message is expunged from expire_altmove ma...
dovecot at dovecot.org
dovecot at dovecot.org
Sun Mar 16 12:29:05 EET 2008
details: http://hg.dovecot.org/dovecot-1.1/rev/bd54359bfb3a
changeset: 7423:bd54359bfb3a
user: Timo Sirainen <tss at iki.fi>
date: Sun Mar 16 12:28:58 2008 +0200
description:
If first message is expunged from expire_altmove mailbox, don't update dict.
diffstat:
3 files changed, 28 insertions(+), 13 deletions(-)
src/plugins/expire/expire-env.c | 11 +++++++++--
src/plugins/expire/expire-env.h | 3 ++-
src/plugins/expire/expire-plugin.c | 27 +++++++++++++++++----------
diffs (118 lines):
diff -r ae746a73e51e -r bd54359bfb3a src/plugins/expire/expire-env.c
--- a/src/plugins/expire/expire-env.c Sun Mar 16 12:10:51 2008 +0200
+++ b/src/plugins/expire/expire-env.c Sun Mar 16 12:28:58 2008 +0200
@@ -105,10 +105,17 @@ bool expire_box_find(struct expire_env *
return expunge_min > 0 || altmove_min > 0;
}
-unsigned int expire_box_find_min_secs(struct expire_env *env, const char *name)
+unsigned int expire_box_find_min_secs(struct expire_env *env, const char *name,
+ bool *altmove_r)
{
unsigned int secs1, secs2;
(void)expire_box_find(env, name, &secs1, &secs2);
- return secs1 < secs2 && secs1 != 0 ? secs1 : secs2;
+ if (secs1 < secs2 && secs1 != 0) {
+ *altmove_r = FALSE;
+ return secs1;
+ } else {
+ *altmove_r = TRUE;
+ return secs2;
+ }
}
diff -r ae746a73e51e -r bd54359bfb3a src/plugins/expire/expire-env.h
--- a/src/plugins/expire/expire-env.h Sun Mar 16 12:10:51 2008 +0200
+++ b/src/plugins/expire/expire-env.h Sun Mar 16 12:28:58 2008 +0200
@@ -10,6 +10,7 @@ bool expire_box_find(struct expire_env *
unsigned int *expunge_secs_r,
unsigned int *altmove_secs_r);
-unsigned int expire_box_find_min_secs(struct expire_env *env, const char *name);
+unsigned int expire_box_find_min_secs(struct expire_env *env, const char *name,
+ bool *altmove_r);
#endif
diff -r ae746a73e51e -r bd54359bfb3a src/plugins/expire/expire-plugin.c
--- a/src/plugins/expire/expire-plugin.c Sun Mar 16 12:10:51 2008 +0200
+++ b/src/plugins/expire/expire-plugin.c Sun Mar 16 12:28:58 2008 +0200
@@ -29,6 +29,7 @@ struct expire_mailbox {
struct expire_mailbox {
union mailbox_module_context module_ctx;
time_t expire_secs;
+ unsigned int altmove:1;
};
struct expire_transaction_context {
@@ -78,16 +79,16 @@ static void first_nonexpunged_timestamp(
for (seq = 2; seq <= hdr->messages_count; seq++) {
if (!mail_index_is_expunged(view, seq)) {
mail_set_seq(mail, seq);
- if (mail_get_save_date(mail, stamp_r) == 0) {
- mail_free(&mail);
- return;
- }
+ if (mail_get_save_date(mail, stamp_r) == 0)
+ break;
}
}
mail_free(&mail);
- /* everything expunged */
- *stamp_r = 0;
+ if (seq > hdr->messages_count) {
+ /* everything expunged */
+ *stamp_r = 0;
+ }
}
static int
@@ -103,7 +104,9 @@ expire_mailbox_transaction_commit(struct
bool update_dict = FALSE;
int ret;
- if (xt->first_expunged) {
+ if (xpr_box->altmove) {
+ /* only moving mails - don't update the move stamps */
+ } else if (xt->first_expunged) {
/* first mail expunged. dict needs updating. */
first_nonexpunged_timestamp(t, &new_stamp);
update_dict = TRUE;
@@ -219,7 +222,8 @@ expire_copy(struct mailbox_transaction_c
copy(t, mail, flags, keywords, dest_mail);
}
-static void mailbox_expire_hook(struct mailbox *box, time_t expire_secs)
+static void
+mailbox_expire_hook(struct mailbox *box, time_t expire_secs, bool altmove)
{
struct expire_mailbox *xpr_box;
@@ -233,6 +237,7 @@ static void mailbox_expire_hook(struct m
box->v.save_finish = expire_save_finish;
box->v.copy = expire_copy;
+ xpr_box->altmove = altmove;
xpr_box->expire_secs = expire_secs;
MODULE_CONTEXT_SET(box, expire_storage_module, xpr_box);
@@ -247,15 +252,17 @@ expire_mailbox_open(struct mail_storage
struct mailbox *box;
string_t *vname;
unsigned int secs;
+ bool altmove;
box = xpr_storage->super.mailbox_open(storage, name, input, flags);
if (box != NULL) {
vname = t_str_new(128);
(void)mail_namespace_get_vname(storage->ns, vname, name);
- secs = expire_box_find_min_secs(expire.env, str_c(vname));
+ secs = expire_box_find_min_secs(expire.env, str_c(vname),
+ &altmove);
if (secs != 0)
- mailbox_expire_hook(box, secs);
+ mailbox_expire_hook(box, secs, altmove);
}
return box;
}
More information about the dovecot-cvs
mailing list