Fixed a bug when no article can be fetched after server timeout if the
connection was restored by news_post().
This commit is contained in:
parent
754363892d
commit
cfcf53be1a
2 changed files with 55 additions and 0 deletions
|
@ -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
|
||||
|
|
45
src/news.c
45
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"),
|
||||
|
|
Loading…
Reference in a new issue