Mercurial > dovecot > core-2.2
changeset 14379:370e1f945c01
Added mail_temp_scan_interval setting and changed its default from 8h -> 1w.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 23 Mar 2012 13:44:54 +0200 |
parents | 091b9f49f24f |
children | 24b3de4952b5 |
files | doc/example-config/conf.d/10-mail.conf src/lib-storage/index/dbox-common/dbox-storage.c src/lib-storage/index/dbox-common/dbox-storage.h src/lib-storage/index/dbox-multi/mdbox-map.c src/lib-storage/index/maildir/maildir-storage.c src/lib-storage/index/maildir/maildir-storage.h src/lib-storage/mail-storage-settings.c src/lib-storage/mail-storage-settings.h |
diffstat | 8 files changed, 23 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/example-config/conf.d/10-mail.conf Fri Mar 23 13:35:05 2012 +0200 +++ b/doc/example-config/conf.d/10-mail.conf Fri Mar 23 13:44:54 2012 +0200 @@ -227,6 +227,10 @@ # some mailbox formats and/or operating systems. #mail_prefetch_count = 0 +# How often to scan for stale temporary files and delete them. These should +# exist only after Dovecot dies in the middle of saving mails. +#mail_temp_scan_interval = 1w + ## ## Maildir-specific settings ##
--- a/src/lib-storage/index/dbox-common/dbox-storage.c Fri Mar 23 13:35:05 2012 +0200 +++ b/src/lib-storage/index/dbox-common/dbox-storage.c Fri Mar 23 13:44:54 2012 +0200 @@ -147,15 +147,18 @@ dbox_cleanup_if_exists(struct mailbox_list *list, const char *path) { struct stat st; + unsigned int interval = list->mail_set->mail_temp_scan_interval; if (stat(path, &st) < 0) return FALSE; /* check once in a while if there are temp files to clean up */ - if (st.st_atime > st.st_ctime + DBOX_TMP_DELETE_SECS) { + if (interval == 0) { + /* disabled */ + } else if (st.st_atime > st.st_ctime + DBOX_TMP_DELETE_SECS) { /* there haven't been any changes to this directory since we last checked it. */ - } else if (st.st_atime < ioloop_time - DBOX_TMP_SCAN_SECS) { + } else if (st.st_atime < ioloop_time - interval) { /* time to scan */ const char *prefix = mailbox_list_get_global_temp_prefix(list);
--- a/src/lib-storage/index/dbox-common/dbox-storage.h Fri Mar 23 13:35:05 2012 +0200 +++ b/src/lib-storage/index/dbox-common/dbox-storage.h Fri Mar 23 13:44:54 2012 +0200 @@ -18,8 +18,6 @@ #define DBOX_TRASH_DIR_NAME "trash" #define DBOX_MAILDIR_NAME "dbox-Mails" -/* How often to scan for stale temp files (based on dir's atime) */ -#define DBOX_TMP_SCAN_SECS (8*60*60) /* Delete temp files having ctime older than this. */ #define DBOX_TMP_DELETE_SECS (36*60*60)
--- a/src/lib-storage/index/dbox-multi/mdbox-map.c Fri Mar 23 13:35:05 2012 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-map.c Fri Mar 23 13:44:54 2012 +0200 @@ -133,16 +133,20 @@ static void mdbox_map_cleanup(struct mdbox_map *map) { + unsigned int interval = + MAP_STORAGE(map)->set->mail_temp_scan_interval; struct stat st; if (stat(map->path, &st) < 0) return; /* check once in a while if there are temp files to clean up */ - if (st.st_atime > st.st_ctime + DBOX_TMP_DELETE_SECS) { + if (interval == 0) { + /* disabled */ + } else if (st.st_atime > st.st_ctime + DBOX_TMP_DELETE_SECS) { /* there haven't been any changes to this directory since we last checked it. */ - } else if (st.st_atime < ioloop_time - DBOX_TMP_SCAN_SECS) { + } else if (st.st_atime < ioloop_time - interval) { /* time to scan */ (void)unlink_old_files(map->path, DBOX_TEMP_FILE_PREFIX, ioloop_time - DBOX_TMP_DELETE_SECS);
--- a/src/lib-storage/index/maildir/maildir-storage.c Fri Mar 23 13:35:05 2012 +0200 +++ b/src/lib-storage/index/maildir/maildir-storage.c Fri Mar 23 13:44:54 2012 +0200 @@ -201,6 +201,7 @@ static int maildir_check_tmp(struct mail_storage *storage, const char *dir) { + unsigned int interval = storage->set->mail_temp_scan_interval; const char *path; struct stat st; @@ -218,10 +219,12 @@ return -1; } - if (st.st_atime > st.st_ctime + MAILDIR_TMP_DELETE_SECS) { + if (interval == 0) { + /* disabled */ + } else if (st.st_atime > st.st_ctime + MAILDIR_TMP_DELETE_SECS) { /* the directory should be empty. we won't do anything until ctime changes. */ - } else if (st.st_atime < ioloop_time - MAILDIR_TMP_SCAN_SECS) { + } else if (st.st_atime < ioloop_time - interval) { /* time to scan */ (void)unlink_old_files(path, "", ioloop_time - MAILDIR_TMP_DELETE_SECS);
--- a/src/lib-storage/index/maildir/maildir-storage.h Fri Mar 23 13:35:05 2012 +0200 +++ b/src/lib-storage/index/maildir/maildir-storage.h Fri Mar 23 13:44:54 2012 +0200 @@ -31,8 +31,6 @@ calculating file's virtual size (added missing CRs). */ #define MAILDIR_EXTRA_VIRTUAL_SIZE 'W' -/* How often to scan tmp/ directory for old files (based on dir's atime) */ -#define MAILDIR_TMP_SCAN_SECS (8*60*60) /* Delete files having ctime older than this from tmp/. 36h is standard. */ #define MAILDIR_TMP_DELETE_SECS (36*60*60)
--- a/src/lib-storage/mail-storage-settings.c Fri Mar 23 13:35:05 2012 +0200 +++ b/src/lib-storage/mail-storage-settings.c Fri Mar 23 13:44:54 2012 +0200 @@ -37,6 +37,7 @@ DEF(SET_TIME, mailbox_idle_check_interval), DEF(SET_UINT, mail_max_keyword_length), DEF(SET_TIME, mail_max_lock_timeout), + DEF(SET_TIME, mail_temp_scan_interval), DEF(SET_BOOL, mail_save_crlf), DEF(SET_ENUM, mail_fsync), DEF(SET_BOOL, mmap_disable), @@ -66,6 +67,7 @@ .mailbox_idle_check_interval = 30, .mail_max_keyword_length = 50, .mail_max_lock_timeout = 0, + .mail_temp_scan_interval = 7*24*60*60, .mail_save_crlf = FALSE, .mail_fsync = "optimized:never:always", .mmap_disable = FALSE,
--- a/src/lib-storage/mail-storage-settings.h Fri Mar 23 13:35:05 2012 +0200 +++ b/src/lib-storage/mail-storage-settings.h Fri Mar 23 13:44:54 2012 +0200 @@ -22,6 +22,7 @@ unsigned int mailbox_idle_check_interval; unsigned int mail_max_keyword_length; unsigned int mail_max_lock_timeout; + unsigned int mail_temp_scan_interval; bool mail_save_crlf; const char *mail_fsync; bool mmap_disable;