From: Marco Bettini Date: Wed, 28 Jun 2023 14:12:46 +0000 (+0000) Subject: lib-storage: dbox - Use mail_metadata_accessed_event() X-Git-Tag: 2.4.0~2637 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=68f9cb64e03cd8c2ab08acf5b7a633228efe7aa8;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: dbox - Use mail_metadata_accessed_event() --- diff --git a/src/lib-storage/index/dbox-common/dbox-file.c b/src/lib-storage/index/dbox-common/dbox-file.c index 251c0a502b..e447b2070d 100644 --- a/src/lib-storage/index/dbox-common/dbox-file.c +++ b/src/lib-storage/index/dbox-common/dbox-file.c @@ -240,7 +240,7 @@ int dbox_file_open_primary(struct dbox_file *file, bool *notfound_r) return dbox_file_open_full(file, FALSE, notfound_r); } -int dbox_file_stat(struct dbox_file *file, struct stat *st_r) +int dbox_file_stat(struct dbox_file *file, struct event *event, struct stat *st_r) { const char *path; bool alt = FALSE; @@ -253,6 +253,7 @@ int dbox_file_stat(struct dbox_file *file, struct stat *st_r) } return 0; } + mail_metadata_accessed_event(event); /* try the primary path first */ path = file->primary_path; diff --git a/src/lib-storage/index/dbox-common/dbox-file.h b/src/lib-storage/index/dbox-common/dbox-file.h index b697325a15..2f8f50e632 100644 --- a/src/lib-storage/index/dbox-common/dbox-file.h +++ b/src/lib-storage/index/dbox-common/dbox-file.h @@ -148,7 +148,7 @@ void dbox_file_close(struct dbox_file *file); /* fstat() or stat() the file. If file is already deleted, fails with errno=ENOENT. */ -int dbox_file_stat(struct dbox_file *file, struct stat *st_r); +int dbox_file_stat(struct dbox_file *file, struct event *event, struct stat *st_r); /* Try to lock the dbox file. Returns 1 if ok, 0 if already locked by someone else, -1 if error. */ diff --git a/src/lib-storage/index/dbox-common/dbox-mail.c b/src/lib-storage/index/dbox-common/dbox-mail.c index 088cfc6609..9595faf5e9 100644 --- a/src/lib-storage/index/dbox-common/dbox-mail.c +++ b/src/lib-storage/index/dbox-common/dbox-mail.c @@ -56,7 +56,9 @@ int dbox_mail_metadata_read(struct dbox_mail *mail, struct dbox_file **file_r) /* we just messed up mail's input stream by reading metadata */ i_stream_seek((*file_r)->input, offset); i_stream_sync(mail->imail.data.stream); - } + } else + mail_metadata_accessed_event(mail_event(&mail->imail.mail.mail)); + return 0; } @@ -150,7 +152,8 @@ int dbox_mail_get_save_date(struct mail *_mail, time_t *date_r) return -1; _mail->transaction->stats.stat_lookup_count++; - if (dbox_file_stat(mail->open_file, &st) < 0) { + if (dbox_file_stat(mail->open_file, + mail_event(&mail->imail.mail.mail), &st) < 0) { if (errno == ENOENT) mail_set_expunged(_mail); return -1; diff --git a/src/lib-storage/index/dbox-single/sdbox-mail.c b/src/lib-storage/index/dbox-single/sdbox-mail.c index 4156658d9b..82b4d493d0 100644 --- a/src/lib-storage/index/dbox-single/sdbox-mail.c +++ b/src/lib-storage/index/dbox-single/sdbox-mail.c @@ -71,7 +71,8 @@ sdbox_mail_get_special(struct mail *_mail, enum mail_fetch_field field, return -1; _mail->transaction->stats.fstat_lookup_count++; - if (dbox_file_stat(mail->open_file, &st) < 0) { + if (dbox_file_stat(mail->open_file, + mail_event(&mail->imail.mail.mail), &st) < 0) { if (errno == ENOENT) mail_set_expunged(_mail); return -1; @@ -84,7 +85,8 @@ sdbox_mail_get_special(struct mail *_mail, enum mail_fetch_field field, return -1; _mail->transaction->stats.fstat_lookup_count++; - if (dbox_file_stat(mail->open_file, &st) < 0) { + if (dbox_file_stat(mail->open_file, + mail_event(&mail->imail.mail.mail), &st) < 0) { if (errno == ENOENT) mail_set_expunged(_mail); return -1; diff --git a/src/lib-storage/index/dbox-single/sdbox-sync.c b/src/lib-storage/index/dbox-single/sdbox-sync.c index 1e8879ecf7..12df5261a2 100644 --- a/src/lib-storage/index/dbox-single/sdbox-sync.c +++ b/src/lib-storage/index/dbox-single/sdbox-sync.c @@ -10,7 +10,7 @@ #define SDBOX_REBUILD_COUNT 3 static void -dbox_sync_file_move_if_needed(struct dbox_file *file, +dbox_sync_file_move_if_needed(struct dbox_file *file, struct event *event, enum sdbox_sync_entry_type type) { struct stat st; @@ -21,7 +21,7 @@ dbox_sync_file_move_if_needed(struct dbox_file *file, !move_to_alt) { /* unopened dbox files default to primary dir. stat the file to update its location. */ - (void)dbox_file_stat(file, &st); + (void)dbox_file_stat(file, event, &st); } if (move_to_alt != dbox_file_is_in_alt(file)) { @@ -56,7 +56,7 @@ static void sdbox_sync_file(struct sdbox_sync_context *ctx, mail_index_update_flags(ctx->trans, seq, modify_type, (enum mail_flags)DBOX_INDEX_FLAG_ALT); file = sdbox_file_init(ctx->mbox, uid); - dbox_sync_file_move_if_needed(file, type); + dbox_sync_file_move_if_needed(file, ctx->mbox->box.event, type); dbox_file_unref(&file); break; }