X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=mx.c;h=28eb914ccdd7feeb07fe8b0c1bc9e2ee80d1f354;hb=5f6b586de5a46f2359a4fc392fd89f1716d847a3;hp=6cc2a3b258bb4b072bb1556286baec265cb923f1;hpb=ba5e3af4ea19e1d20c80941c077039871ec84258;p=apps%2Fmadmutt.git diff --git a/mx.c b/mx.c index 6cc2a3b..28eb914 100644 --- a/mx.c +++ b/mx.c @@ -13,11 +13,14 @@ #endif #include "mutt.h" +#include "buffy.h" +#include "ascii.h" #include "mx.h" #include "mbox.h" #include "mh.h" #include "rfc2047.h" #include "sort.h" +#include "thread.h" #include "copy.h" #include "keymap.h" #include "url.h" @@ -42,10 +45,6 @@ #include "nntp/mx_nntp.h" #endif -#ifdef BUFFY_SIZE -#include "buffy.h" -#endif - #ifdef USE_DOTLOCK #include "dotlock.h" #endif @@ -199,6 +198,7 @@ int mx_lock_file (const char *path, int fd, int excl, int dot, int timeout) count = 0; attempt = 0; + prev_sb.st_size = 0; while (fcntl (fd, F_SETLK, &lck) == -1) { struct stat sb; @@ -487,7 +487,7 @@ static int mx_open_mailbox_append (CONTEXT * ctx, int flags) } return (-1); } - fseek (ctx->fp, 0, 2); + fseeko (ctx->fp, 0, 2); break; case M_MH: @@ -1433,3 +1433,45 @@ 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; + 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 +#ifdef USE_IMAP + && magic != M_IMAP +#endif + ) + continue; + 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); + } + + mutt_clear_error (); + + return (0); +#endif +}