From cfcf53be1a20d7db7713dec88f8b4f2609e4b649 Mon Sep 17 00:00:00 2001 From: Sergey Vlasov Date: Thu, 3 May 2001 18:11:22 +0000 Subject: [PATCH] Fixed a bug when no article can be fetched after server timeout if the connection was restored by news_post(). --- ChangeLog.claws | 10 ++++++++++ src/news.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/ChangeLog.claws b/ChangeLog.claws index 377994154..4ccc8a2ee 100644 --- a/ChangeLog.claws +++ b/ChangeLog.claws @@ -1,3 +1,13 @@ +2001-05-03 [sergey] + + * src/news.c: fixed a bug when no article can be fetched after + server timeout if the connection was restored by news_post(): + (news_select_group): new function. + (news_fetch_msg): call news_select_group() before fetching + article. + (news_get_uncached_articles): set session->group after successful + GROUP command. + 2001-05-03 [hoa] * src/defs.h diff --git a/src/news.c b/src/news.c index 473d73330..fcf7c9581 100644 --- a/src/news.c +++ b/src/news.c @@ -57,6 +57,8 @@ static gint news_get_header (NNTPSession *session, gint num, gchar *filename); +static gint news_select_group (NNTPSession *session, + const char *group); static GSList *news_get_uncached_articles(NNTPSession *session, FolderItem *item, gint cache_last, @@ -243,6 +245,14 @@ gchar *news_fetch_msg(Folder *folder, FolderItem *item, gint num) return NULL; } + ok = news_select_group(NNTP_SESSION(REMOTE_FOLDER(folder)->session), + item->path); + if (ok != NN_SUCCESS) { + g_warning(_("can't select group %s\n"), item->path); + g_free(filename); + return NULL; + } + debug_print(_("getting article %d...\n"), num); ok = news_get_article(NNTP_SESSION(REMOTE_FOLDER(folder)->session), num, filename); @@ -321,6 +331,36 @@ static gint news_get_header(NNTPSession *session, gint num, gchar *filename) return news_get_article_cmd(session, "HEAD", num, filename); } +/** + * news_select_group: + * @session: Active NNTP session. + * @group: Newsgroup name. + * + * Select newsgroup @group with the GROUP command if it is not already + * selected in @session. + * + * Return value: NNTP result code. + **/ +static gint news_select_group(NNTPSession *session, + const char *group) +{ + gint ok; + gint num, first, last; + + if (g_strcasecmp(session->group, group) == 0) + return NN_SUCCESS; + + g_free(session->group); + session->group = NULL; + + ok = nntp_group(session->nntp_sock, group, &num, &first, &last); + + if (ok == NN_SUCCESS) + session->group = g_strdup(group); + + return ok; +} + static GSList *news_get_uncached_articles(NNTPSession *session, FolderItem *item, gint cache_last, gint *rfirst, gint *rlast) @@ -340,6 +380,9 @@ static GSList *news_get_uncached_articles(NNTPSession *session, g_return_val_if_fail(item->folder != NULL, NULL); g_return_val_if_fail(item->folder->type == F_NEWS, NULL); + g_free(session->group); + session->group = NULL; + ok = nntp_group(session->nntp_sock, item->path, &num, &first, &last); if (ok != NN_SUCCESS) { @@ -347,6 +390,8 @@ static GSList *news_get_uncached_articles(NNTPSession *session, return NULL; } + session->group = g_strdup(item->path); + /* calculate getting overview range */ if (first > last) { log_warning(_("invalid article range: %d - %d\n"), -- 2.25.1