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;
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);
#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)
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