]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
dbox: Avoid opening mail file when getting mail's saved timestamp
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 19 Jun 2023 21:11:17 +0000 (00:11 +0300)
committermarkus.valentin <markus.valentin@open-xchange.com>
Wed, 21 Jun 2023 11:26:19 +0000 (11:26 +0000)
Just stat() the file, no open() necessary.

src/lib-storage/index/dbox-common/dbox-mail.c

index 49279f94363ff0d56615f2c81d02e13cc7cbb996..0e9696c302cc3190ecb3c42efcb23bf4de6ecd07 100644 (file)
@@ -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;