X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=mx.c;h=0d2ec9ce8766248f53b2011c34083a817495734f;hp=6cc2a3b258bb4b072bb1556286baec265cb923f1;hb=13b3b36c8f696aea26b7c60444f2baa4858b004d;hpb=ba5e3af4ea19e1d20c80941c077039871ec84258 diff --git a/mx.c b/mx.c index 6cc2a3b..0d2ec9c 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: @@ -694,7 +694,7 @@ static int trash_append (CONTEXT * ctx) } /* save changes and close mailbox */ -int mx_close_mailbox (CONTEXT * ctx, int *index_hint) +static int _mx_close_mailbox (CONTEXT * ctx, int *index_hint) { int i, move_messages = 0, purge = 1, read_msgs = 0; int check; @@ -899,6 +899,14 @@ int mx_close_mailbox (CONTEXT * ctx, int *index_hint) return 0; } +int mx_close_mailbox (CONTEXT * ctx, int *index_hint) { + int ret = 0; + if (!ctx) + return (0); + ret = _mx_close_mailbox (ctx, index_hint); + sidebar_set_buffystats (ctx); + return (ret); +} /* update a Context structure's internal tables. */ @@ -986,7 +994,7 @@ void mx_update_tables (CONTEXT * ctx, int committing) * 0 success * -1 error */ -int mx_sync_mailbox (CONTEXT * ctx, int *index_hint) +static int _mx_sync_mailbox (CONTEXT * ctx, int *index_hint) { int rc, i; int purge = 1; @@ -1077,9 +1085,6 @@ int mx_sync_mailbox (CONTEXT * ctx, int *index_hint) return 0; } - /* update sidebar counts */ - sidebar_set_buffystats (ctx); - /* if we haven't deleted any messages, we don't need to resort */ /* ... except for certain folder formats which need "unsorted" * sort order in order to synchronize folders. @@ -1102,6 +1107,12 @@ int mx_sync_mailbox (CONTEXT * ctx, int *index_hint) return (rc); } +int mx_sync_mailbox (CONTEXT* ctx, int* index_hint) { + int ret = _mx_sync_mailbox (ctx, index_hint); + sidebar_set_buffystats (ctx); + return (ret); +} + /* args: * dest destintation mailbox * hdr message being copied (required for maildir support, because @@ -1433,3 +1444,43 @@ 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; + BUFFY* b = NULL; + + if (list_empty(Incoming)) { + mutt_error (_("No mailboxes defined.")); + return (1); + } + + 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; + sidebar_set_current (b->path); + sidebar_draw (CurrentMenu); + if ((ctx = mx_open_mailbox (b->path, + M_READONLY | M_NOSORT | M_COUNT, + NULL)) != NULL) + mx_close_mailbox (ctx, 0); + } + mutt_clear_error (); + + if (Context && Context->path) + sidebar_set_current (Context->path); + sidebar_draw (CurrentMenu); + + return (0); +#endif +}