dovecot-2.2: maildir: Remember the mail's GUID/filename in memor...
dovecot at dovecot.org
dovecot at dovecot.org
Sun May 20 03:26:31 EEST 2012
details: http://hg.dovecot.org/dovecot-2.2/rev/96ce9c0c6f05
changeset: 14415:96ce9c0c6f05
user: Timo Sirainen <tss at iki.fi>
date: Wed Apr 04 05:34:11 2012 +0300
description:
maildir: Remember the mail's GUID/filename in memory once it's fetched once.
This allows retrieving it later even if the message gets expunged.
diffstat:
src/lib-storage/index/index-mail.h | 2 +-
src/lib-storage/index/maildir/maildir-mail.c | 21 ++++++++++++++++-----
2 files changed, 17 insertions(+), 6 deletions(-)
diffs (67 lines):
diff -r cc734436c140 -r 96ce9c0c6f05 src/lib-storage/index/index-mail.h
--- a/src/lib-storage/index/index-mail.h Wed Apr 04 05:15:49 2012 +0300
+++ b/src/lib-storage/index/index-mail.h Wed Apr 04 05:34:11 2012 +0300
@@ -77,7 +77,7 @@
uint32_t parse_line_num;
struct message_part *parts;
- const char *envelope, *body, *bodystructure, *uid_string, *guid;
+ const char *envelope, *body, *bodystructure, *guid, *filename;
const char *from_envelope;
struct message_part_envelope_data *envelope_data;
diff -r cc734436c140 -r 96ce9c0c6f05 src/lib-storage/index/maildir/maildir-mail.c
--- a/src/lib-storage/index/maildir/maildir-mail.c Wed Apr 04 05:15:49 2012 +0300
+++ b/src/lib-storage/index/maildir/maildir-mail.c Wed Apr 04 05:34:11 2012 +0300
@@ -482,6 +482,11 @@
/* use GUID from uidlist if it exists */
i_assert(!_mail->saving);
+ if (mail->data.guid != NULL) {
+ *value_r = mail->data.guid;
+ return 0;
+ }
+
/* first make sure that we have a refreshed uidlist */
if (maildir_mail_get_fname(mbox, _mail, &fname) <= 0)
return -1;
@@ -490,7 +495,8 @@
MAILDIR_UIDLIST_REC_EXT_GUID);
if (guid != NULL) {
if (*guid != '\0') {
- *value_r = p_strdup(mail->data_pool, guid);
+ *value_r = mail->data.guid =
+ p_strdup(mail->data_pool, guid);
return 0;
}
@@ -503,9 +509,14 @@
}
/* default to base filename: */
+ if (maildir_mail_get_special(_mail, MAIL_FETCH_UIDL_FILE_NAME,
+ value_r) < 0)
+ return -1;
+ mail->data.guid = mail->data.filename;
+ return 0;
case MAIL_FETCH_UIDL_FILE_NAME:
- if (mail->data.guid != NULL) {
- *value_r = mail->data.guid;
+ if (mail->data.filename != NULL) {
+ *value_r = mail->data.filename;
return 0;
}
if (fname != NULL) {
@@ -521,10 +532,10 @@
fname = fname != NULL ? fname + 1 : path;
}
end = strchr(fname, MAILDIR_INFO_SEP);
- mail->data.guid = end == NULL ?
+ mail->data.filename = end == NULL ?
p_strdup(mail->data_pool, fname) :
p_strdup_until(mail->data_pool, fname, end);
- *value_r = mail->data.guid;
+ *value_r = mail->data.filename;
return 0;
case MAIL_FETCH_UIDL_BACKEND:
uidl = maildir_uidlist_lookup_ext(mbox->uidlist, _mail->uid,
More information about the dovecot-cvs
mailing list