Mercurial > dovecot > original-hg > dovecot-1.2
changeset 9041:c8d63b42e9cc HEAD
Added mail_index_unlink().
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 17 May 2009 17:54:01 -0400 |
parents | 533e4829212a |
children | 5e60bba2c748 |
files | src/lib-index/mail-index.c src/lib-index/mail-index.h src/lib-index/mail-transaction-log-private.h src/lib-index/mail-transaction-log.h |
diffstat | 4 files changed, 39 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-index/mail-index.c Sun May 17 17:30:58 2009 -0400 +++ b/src/lib-index/mail-index.c Sun May 17 17:54:01 2009 -0400 @@ -470,6 +470,41 @@ index->opened = FALSE; } +int mail_index_unlink(struct mail_index *index) +{ + const char *path; + int last_errno = 0; + + if (MAIL_INDEX_IS_IN_MEMORY(index)) + return 0; + + /* main index */ + if (unlink(index->filepath) < 0 && errno != ENOENT) + last_errno = errno; + + /* logs */ + path = t_strconcat(index->filepath, MAIL_TRANSACTION_LOG_SUFFIX, NULL); + if (unlink(path) < 0 && errno != ENOENT) + last_errno = errno; + + path = t_strconcat(index->filepath, + MAIL_TRANSACTION_LOG_SUFFIX".2", NULL); + if (unlink(path) < 0 && errno != ENOENT) + last_errno = errno; + + /* cache */ + path = t_strconcat(index->filepath, MAIL_CACHE_FILE_SUFFIX, NULL); + if (unlink(path) < 0 && errno != ENOENT) + last_errno = errno; + + if (last_errno == 0) + return 0; + else { + errno = last_errno; + return -1; + } +} + int mail_index_reopen_if_changed(struct mail_index *index) { struct stat st1, st2;
--- a/src/lib-index/mail-index.h Sun May 17 17:30:58 2009 -0400 +++ b/src/lib-index/mail-index.h Sun May 17 17:54:01 2009 -0400 @@ -190,6 +190,8 @@ int mail_index_open(struct mail_index *index, enum mail_index_open_flags flags, enum file_lock_method lock_method); void mail_index_close(struct mail_index *index); +/* unlink() all the index files. */ +int mail_index_unlink(struct mail_index *index); /* Returns TRUE if index is currently in memory. */ bool mail_index_is_in_memory(struct mail_index *index);
--- a/src/lib-index/mail-transaction-log-private.h Sun May 17 17:30:58 2009 -0400 +++ b/src/lib-index/mail-transaction-log-private.h Sun May 17 17:54:01 2009 -0400 @@ -4,8 +4,6 @@ #include "file-dotlock.h" #include "mail-transaction-log.h" -#define MAIL_TRANSACTION_LOG_SUFFIX ".log" - /* Synchronization can take a while sometimes, especially when copying lots of mails. */ #define MAIL_TRANSCATION_LOG_LOCK_TIMEOUT (3*60)
--- a/src/lib-index/mail-transaction-log.h Sun May 17 17:30:58 2009 -0400 +++ b/src/lib-index/mail-transaction-log.h Sun May 17 17:54:01 2009 -0400 @@ -4,6 +4,8 @@ struct mail_index; struct mail_index_transaction; +#define MAIL_TRANSACTION_LOG_SUFFIX ".log" + #define MAIL_TRANSACTION_LOG_MAJOR_VERSION 1 #define MAIL_TRANSACTION_LOG_MINOR_VERSION 2 #define MAIL_TRANSACTION_LOG_HEADER_MIN_SIZE 24