From b30370f4af4cffda4d6b388acc7467387d082069 Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Sat, 26 May 2007 19:25:02 +0200 Subject: [PATCH] LISTGROUP isn't as efficient as XOVER. Only use it if needed. Signed-off-by: Pierre Habouzit --- nntp/newsrc.c | 2 +- nntp/nntp.c | 47 +++++++++++++++++++++++------------------------ 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/nntp/newsrc.c b/nntp/newsrc.c index 0eac040..59ca74f 100644 --- a/nntp/newsrc.c +++ b/nntp/newsrc.c @@ -161,7 +161,7 @@ static int nntp_parse_cacheindex (NNTP_SERVER * news) if (!news || !news->conn || !news->conn->account.host) return -1; unset_option (OPTNEWSCACHE); - if (!NewsCacheDir || !*NewsCacheDir) + if (m_strisempty(NewsCacheDir)) return 0; m_strcpy(dir, sizeof(dir), NewsCacheDir); diff --git a/nntp/nntp.c b/nntp/nntp.c index 6b1888e..aad5bb2 100644 --- a/nntp/nntp.c +++ b/nntp/nntp.c @@ -627,7 +627,7 @@ static int add_xover_line (char *line, void *c) nntp_parse_xover (ctx, line, ctx->hdrs[ctx->msgcount]); num = ctx->hdrs[ctx->msgcount]->article_num; - if (bit_isset(&fc->messages, num)) { + if (num >= fc->first && num <= fc->last) { ctx->msgcount++; if (num > data->lastLoaded) data->lastLoaded = num; @@ -635,9 +635,9 @@ static int add_xover_line (char *line, void *c) total = fc->last - fc->first + 1; if (!ctx->quiet && fc->msg && ReadInc && (num % ReadInc == 0)) mutt_message ("%s %d/%d", fc->msg, num, total); - } - else + } else { header_delete(&ctx->hdrs[ctx->msgcount]); /* skip it */ + } return 0; } @@ -663,22 +663,6 @@ static int nntp_fetch_headers(CONTEXT * ctx, int first, int last) fc.ctx = ctx; fc.first = first; fc.last = last; - bits_init(&fc.messages); - - if (nntp_data->nserv->hasLISTGROUP) { - snprintf (buf, sizeof (buf), "LISTGROUP %s\r\n", nntp_data->group); - if (mutt_nntp_fetch(nntp_data, buf, NULL, NULL, - nntp_fetch_numbers, &fc, 0)) - { - mutt_error (_("LISTGROUP command failed: %s"), buf); - sleep (2); - bits_wipe(&fc.messages); - return -1; - } - } else { - for (num = first; num <= last; num++) - bit_set(&fc.messages, num); - } /* CACHE: must be loaded xover cache here */ num = nntp_data->lastCached - first + 1; @@ -715,7 +699,6 @@ static int nntp_fetch_headers(CONTEXT * ctx, int first, int last) } num = last - first + 1; if (num <= 0) { - bits_wipe(&fc.messages); return 0; } @@ -735,11 +718,26 @@ static int nntp_fetch_headers(CONTEXT * ctx, int first, int last) mx_update_context (ctx, ctx->msgcount - oldmsgcount); if (ret != 0) { mutt_error (_("XOVER command failed: %s"), buf); - bits_wipe(&fc.messages); return -1; } - /* fetched OK */ } else { + bits_init(&fc.messages); + + if (nntp_data->nserv->hasLISTGROUP) { + snprintf (buf, sizeof (buf), "LISTGROUP %s\r\n", nntp_data->group); + if (mutt_nntp_fetch(nntp_data, buf, NULL, NULL, + nntp_fetch_numbers, &fc, 0)) + { + mutt_error (_("LISTGROUP command failed: %s"), buf); + sleep (2); + bits_wipe(&fc.messages); + return -1; + } + } else { + for (num = first; num <= last; num++) + bit_set(&fc.messages, num); + } + for (current = first; current <= last; current++) { HEADER *h; @@ -770,14 +768,15 @@ static int nntp_fetch_headers(CONTEXT * ctx, int first, int last) if (current > nntp_data->lastLoaded) nntp_data->lastLoaded = current; } + bits_wipe(&fc.messages); } - bits_wipe(&fc.messages); + nntp_data->lastLoaded = last; mutt_clear_error (); return 0; } -/* +/* * currently, nntp "mailbox" is "newsgroup" */ static int nntp_open_mailbox (CONTEXT * ctx) -- 2.20.1