From: Marco Bettini Date: Tue, 28 Feb 2023 10:15:50 +0000 (+0000) Subject: dbox: dbox_mailbox_open() - Infer last_temp_file_scan from dir's atime if 0 X-Git-Tag: 2.3.21~90 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f18b8e9f462c391203fb44e1a5cfda6a92d150bc;p=thirdparty%2Fdovecot%2Fcore.git dbox: dbox_mailbox_open() - Infer last_temp_file_scan from dir's atime if 0 --- diff --git a/src/lib-storage/index/dbox-common/dbox-storage.c b/src/lib-storage/index/dbox-common/dbox-storage.c index 41457f66a3..cbf5de30df 100644 --- a/src/lib-storage/index/dbox-common/dbox-storage.c +++ b/src/lib-storage/index/dbox-common/dbox-storage.c @@ -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); }