From: Aki Tuomi Date: Thu, 23 Mar 2017 12:08:30 +0000 (+0200) Subject: lib-storage: Indicate mail is being autoexpunged X-Git-Tag: 2.3.0.rc1~1857 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6c51e3c3dc8dc5dc6fef2280b7c2c9ebef3de8f0;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Indicate mail is being autoexpunged This way plugins, such as mail_log, can detect this. --- diff --git a/src/lib-storage/mail-autoexpunge.c b/src/lib-storage/mail-autoexpunge.c index dbbd2bb969..eec43bb00a 100644 --- a/src/lib-storage/mail-autoexpunge.c +++ b/src/lib-storage/mail-autoexpunge.c @@ -118,7 +118,7 @@ mailbox_autoexpunge(struct mailbox *box, unsigned int interval_time, /* max_mails is still being reached -> expunge. don't even check saved-dates before we're below max_mails. */ - mail_expunge(mail); + mail_autoexpunge(mail); count++; } else if (interval_time == 0) { /* only max_mails is used. nothing further to do. */ @@ -126,7 +126,7 @@ mailbox_autoexpunge(struct mailbox *box, unsigned int interval_time, } else if (mail_get_save_date(mail, ×tamp) == 0) { if (I_MAX(last_rename_stamp, timestamp) > expire_time) break; - mail_expunge(mail); + mail_autoexpunge(mail); count++; } else if (mailbox_get_last_mail_error(box) == MAIL_ERROR_EXPUNGED) { /* already expunged */ diff --git a/src/lib-storage/mail-storage-private.h b/src/lib-storage/mail-storage-private.h index e954f82188..f9e0b44ffa 100644 --- a/src/lib-storage/mail-storage-private.h +++ b/src/lib-storage/mail-storage-private.h @@ -521,6 +521,8 @@ struct mail_private { ARRAY(union mail_module_context *) module_contexts; const char *get_stream_reason; + + bool autoexpunged:1; }; struct mailbox_list_context { @@ -721,6 +723,9 @@ void mail_storage_copy_list_error(struct mail_storage *storage, void mail_storage_copy_error(struct mail_storage *dest, struct mail_storage *src); +/* Indicate mail being expunged by autoexpunge */ +void mail_autoexpunge(struct mail *mail); + /* Returns TRUE if everything should already be in memory after this call or if prefetching is not supported, i.e. the caller shouldn't do more prefetching before this message is handled. */ diff --git a/src/lib-storage/mail.c b/src/lib-storage/mail.c index d48341aea1..4374cd945c 100644 --- a/src/lib-storage/mail.c +++ b/src/lib-storage/mail.c @@ -399,6 +399,14 @@ void mail_expunge(struct mail *mail) } T_END; } +void mail_autoexpunge(struct mail *mail) +{ + struct mail_private *p = (struct mail_private *)mail; + p->autoexpunged = TRUE; + mail_expunge(mail); + p->autoexpunged = FALSE; +} + void mail_set_expunged(struct mail *mail) { mail_storage_set_error(mail->box->storage, MAIL_ERROR_EXPUNGED,