Mercurial > dovecot > original-hg > dovecot-1.2
diff src/lib-index/mail-transaction-log.c @ 5881:7b7ce27f2b13 HEAD
Delete over 30 minutes old .log.2 files when opening indexes.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 03 Jul 2007 04:22:40 +0300 |
parents | a9df50952600 |
children | 181aa61c182a |
line wrap: on
line diff
--- a/src/lib-index/mail-transaction-log.c Tue Jul 03 04:11:41 2007 +0300 +++ b/src/lib-index/mail-transaction-log.c Tue Jul 03 04:22:40 2007 +0300 @@ -49,6 +49,29 @@ return log; } +static void mail_transaction_log_2_unlink_old(struct mail_transaction_log *log) +{ + struct stat st; + const char *path; + + path = t_strconcat(log->index->filepath, + MAIL_TRANSACTION_LOG_SUFFIX".2", NULL); + if (stat(path, &st) < 0) { + if (errno != ENOENT && errno != ESTALE) { + mail_index_set_error(log->index, + "stat(%s) failed: %m", path); + } + return; + } + + if (st.st_mtime + MAIL_TRANSACTION_LOG2_STALE_SECS <= ioloop_time) { + if (unlink(path) < 0 && errno != ENOENT) { + mail_index_set_error(log->index, + "unlink(%s) failed: %m", path); + } + } +} + int mail_transaction_log_open(struct mail_transaction_log *log) { struct mail_transaction_log_file *file; @@ -70,8 +93,8 @@ log->open_file = file; return ret; } - mail_transaction_log_set_head(log, file); + mail_transaction_log_2_unlink_old(log); return 1; }