X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=mx.c;h=4bbbaf1203c8cefc5cb9f66aebd3680ea9bee27d;hb=546433d312df43754962a34eac05fee84d73a455;hp=27947b4b1847e87979ad56bff3b1e35e00d0b5d7;hpb=355d6c883e8aafb8f424c22aa576cf8262ed9e58;p=apps%2Fmadmutt.git diff --git a/mx.c b/mx.c index 27947b4..4bbbaf1 100644 --- a/mx.c +++ b/mx.c @@ -13,6 +13,7 @@ #endif #include "mutt.h" +#include "buffy.h" #include "ascii.h" #include "mx.h" #include "mbox.h" @@ -44,10 +45,6 @@ #include "nntp/mx_nntp.h" #endif -#ifdef BUFFY_SIZE -#include "buffy.h" -#endif - #ifdef USE_DOTLOCK #include "dotlock.h" #endif @@ -1436,3 +1433,46 @@ void mx_init (void) { #undef EXITWITHERR #endif /* DEBUG */ } + +int mx_rebuild_cache (void) { +#ifndef USE_HCACHE + mutt_error (_("Support for header caching was not build in.")); + return (1); +#else + int i = 0, magic = 0, imap = 0; + CONTEXT* ctx = NULL; + char* buf = NULL; + BUFFY* b = NULL; + + if (list_empty(Incoming)) { + mutt_error (_("No mailboxes defined.")); + return (1); + } + + ReadInc = 0; + + for (i = 0; i < Incoming->length; i++) { + b = (BUFFY*) Incoming->data[i]; + magic = mx_get_magic (b->path); + if (magic != M_MAILDIR && magic != M_MH && magic != M_IMAP) + continue; + if (magic == M_IMAP) + imap = 1; + buf = str_dup (b->path); + mutt_pretty_mailbox (buf); + mutt_message (_("Rebuilding cache for %s..."), buf); + if ((ctx = mx_open_mailbox (b->path, + M_READONLY | M_QUIET | M_NOSORT | M_COUNT, + NULL)) != NULL) + mx_close_mailbox (ctx, 0); + mem_free (&buf); + } + + if (imap) + imap_logout_all (); + + mutt_clear_error (); + + return (0); +#endif +}