Mercurial > dovecot > original-hg > dovecot-1.2
changeset 7337:31c4ab6a9b4e HEAD
If save time is missing, use the file's ctime instead of current time.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 04 Mar 2008 06:45:01 +0200 |
parents | c150eceb1f6e |
children | d0db93a071e3 |
files | src/lib-storage/index/dbox/dbox-mail.c |
diffstat | 1 files changed, 14 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/dbox/dbox-mail.c Tue Mar 04 06:36:07 2008 +0200 +++ b/src/lib-storage/index/dbox/dbox-mail.c Tue Mar 04 06:45:01 2008 +0200 @@ -8,6 +8,7 @@ #include "dbox-file.h" #include <stdlib.h> +#include <sys/stat.h> struct dbox_mail { struct index_mail imail; @@ -110,6 +111,7 @@ struct dbox_mail *mail = (struct dbox_mail *)_mail; struct index_mail_data *data = &mail->imail.data; struct dbox_file *file; + struct stat st; const char *value; if (index_mail_get_save_date(_mail, date_r) == 0) @@ -120,9 +122,18 @@ value = dbox_file_metadata_get(file, DBOX_METADATA_SAVE_TIME); data->save_date = value == NULL ? 0 : strtoul(value, NULL, 16); - /* if the time is missing or corrupted, use the current time and - cache it */ - *date_r = data->save_date == 0 ? ioloop_time : data->save_date; + + if (data->save_date == 0) { + /* missing / corrupted save time - use the file's ctime */ + i_assert(file->fd != -1); + if (fstat(file->fd, &st) < 0) { + mail_storage_set_critical(_mail->box->storage, + "fstat(%s) failed: %m", file->current_path); + return -1; + } + data->save_date = st.st_ctime; + } + *date_r = data->save_date; return 0; }