From: Timo Sirainen Date: Mon, 19 Jun 2023 21:11:17 +0000 (+0300) Subject: dbox: Avoid opening mail file when getting mail's saved timestamp X-Git-Tag: 2.4.0~2684 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f180cb77b2f27b5f7666ebeb06d1dd268d0fbee2;p=thirdparty%2Fdovecot%2Fcore.git dbox: Avoid opening mail file when getting mail's saved timestamp Just stat() the file, no open() necessary. --- diff --git a/src/lib-storage/index/dbox-common/dbox-mail.c b/src/lib-storage/index/dbox-common/dbox-mail.c index 49279f9436..0e9696c302 100644 --- a/src/lib-storage/index/dbox-common/dbox-mail.c +++ b/src/lib-storage/index/dbox-common/dbox-mail.c @@ -141,18 +141,16 @@ int dbox_mail_get_save_date(struct mail *_mail, time_t *date_r) struct dbox_storage *storage = DBOX_STORAGE(_mail->box->storage); struct dbox_mail *mail = DBOX_MAIL(_mail); struct index_mail_data *data = &mail->imail.data; - struct dbox_file *file; struct stat st; - uoff_t offset; if (index_mail_get_save_date(_mail, date_r) > 0) return 1; - if (storage->v.mail_open(mail, &offset, &file) < 0) + if (storage->v.mail_file_set(mail) < 0) return -1; - _mail->transaction->stats.fstat_lookup_count++; - if (dbox_file_stat(file, &st) < 0) { + _mail->transaction->stats.stat_lookup_count++; + if (dbox_file_stat(mail->open_file, &st) < 0) { if (errno == ENOENT) mail_set_expunged(_mail); return -1;