]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
dbox: dbox_mailbox_open() - Infer last_temp_file_scan from dir's atime if 0
authorMarco Bettini <marco.bettini@open-xchange.com>
Tue, 28 Feb 2023 10:15:50 +0000 (10:15 +0000)
committerMarkus Valentin <markus.valentin@open-xchange.com>
Tue, 25 Apr 2023 07:52:28 +0000 (09:52 +0200)
src/lib-storage/index/dbox-common/dbox-storage.c

index 41457f66a34c53b354052184a12f360411265d41..cbf5de30df5cee95750d1476cc3dac604e6df9c5 100644 (file)
@@ -273,8 +273,15 @@ int dbox_mailbox_open(struct mailbox *box, time_t path_ctime)
                                  MAIL_INDEX_FSYNC_MASK_EXPUNGES);
 
        const struct mail_index_header *hdr = mail_index_get_header(box->view);
+       uint32_t last_temp_file_scan = hdr->last_temp_file_scan;
+       if (last_temp_file_scan == 0) {
+               struct stat stats;
+               if (stat(box_path, &stats) == 0)
+                       last_temp_file_scan = stats.st_atim.tv_sec;
+       }
+
        if (dbox_cleanup_temp_files(box->list, box_path,
-                                   hdr->last_temp_file_scan, path_ctime)) {
+                                   last_temp_file_scan, path_ctime)) {
                /* temp files were scanned. update the last scan timestamp. */
                index_mailbox_update_last_temp_file_scan(box);
        }