]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: dbox - Use mail_metadata_accessed_event()
authorMarco Bettini <marco.bettini@open-xchange.com>
Wed, 28 Jun 2023 14:12:46 +0000 (14:12 +0000)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Tue, 11 Jul 2023 16:38:10 +0000 (16:38 +0000)
src/lib-storage/index/dbox-common/dbox-file.c
src/lib-storage/index/dbox-common/dbox-file.h
src/lib-storage/index/dbox-common/dbox-mail.c
src/lib-storage/index/dbox-single/sdbox-mail.c
src/lib-storage/index/dbox-single/sdbox-sync.c

index 251c0a502b78d64daaa3da12beba695b2d2ea3b4..e447b2070d5542444401adc977c20a76f1d92cff 100644 (file)
@@ -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;
index b697325a15ad9ad803dfcb79bb5b44450ab86b10..2f8f50e632b07b0c29c1aad2f544f6fb07bd7968 100644 (file)
@@ -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. */
index 088cfc6609b8d153bc26179cd8609d852d0c8718..9595faf5e98aab2d0fdc55fdd74b0202d24bb369 100644 (file)
@@ -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;
index 4156658d9b8142a0a7ffd2d87ecdff1d3bc5733f..82b4d493d04163bfc250f6b633df49e57d5e8f7a 100644 (file)
@@ -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;
index 1e8879ecf785246d6a581a8dd8f8de31227ee721..12df5261a28441347af1931e94fe21f4cf36724b 100644 (file)
@@ -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;
        }