dovecot-1.1: If save time is missing, use the file's ctime inste...
dovecot at dovecot.org
dovecot at dovecot.org
Tue Mar 4 06:45:16 EET 2008
details: http://hg.dovecot.org/dovecot-1.1/rev/31c4ab6a9b4e
changeset: 7337:31c4ab6a9b4e
user: Timo Sirainen <tss at iki.fi>
date: Tue Mar 04 06:45:01 2008 +0200
description:
If save time is missing, use the file's ctime instead of current time.
diffstat:
1 file changed, 14 insertions(+), 3 deletions(-)
src/lib-storage/index/dbox/dbox-mail.c | 17 ++++++++++++++---
diffs (41 lines):
diff -r c150eceb1f6e -r 31c4ab6a9b4e src/lib-storage/index/dbox/dbox-mail.c
--- 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 @@ static int dbox_mail_get_save_date(struc
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 @@ static int dbox_mail_get_save_date(struc
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;
}
More information about the dovecot-cvs
mailing list