-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #938 from lwindolf/feed-error-info
Fixes #809: Improved error presentation for feed fetch errors
- Loading branch information
Showing
17 changed files
with
304 additions
and
304 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/** | ||
* @file feed.c feed node and subscription type | ||
* | ||
* Copyright (C) 2003-2020 Lars Windolf <[email protected]> | ||
* Copyright (C) 2003-2021 Lars Windolf <[email protected]> | ||
* Copyright (C) 2004-2006 Nathan J. Conrad <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
|
@@ -178,6 +178,10 @@ feed_add_xml_attributes (nodePtr node, xmlNodePtr feedNode) | |
|
||
if(feed->parseErrors && (strlen(feed->parseErrors->str) > 0)) | ||
xmlNewTextChild(feedNode, NULL, "parseError", feed->parseErrors->str); | ||
|
||
tmp = g_strdup_printf("%d", node->subscription->error); | ||
xmlNewTextChild(feedNode, NULL, "error", tmp); | ||
g_free(tmp); | ||
} | ||
|
||
xmlDocPtr | ||
|
@@ -297,7 +301,6 @@ feed_enrich_item (subscriptionPtr subscription, itemPtr item) | |
update_execute_request (subscription, request, feed_enrich_item_cb, GUINT_TO_POINTER (item->id), FEED_REQ_NO_FEED); | ||
} | ||
|
||
|
||
/* implementation of subscription type interface */ | ||
|
||
static void | ||
|
@@ -310,53 +313,48 @@ feed_process_update_result (subscriptionPtr subscription, const struct updateRes | |
|
||
debug_enter ("feed_process_update_result"); | ||
|
||
if (result->data) { | ||
/* parse the new downloaded feed into feed and itemSet */ | ||
ctxt = feed_create_parser_ctxt (); | ||
ctxt->feed = feed; | ||
ctxt->data = result->data; | ||
ctxt->dataLength = result->size; | ||
ctxt->subscription = subscription; | ||
|
||
/* try to parse the feed */ | ||
if (!feed_parse (ctxt)) { | ||
/* No feed found, display an error */ | ||
node->available = FALSE; | ||
|
||
g_string_prepend (feed->parseErrors, _("<p>Could not detect the type of this feed! Please check if the source really points to a resource provided in one of the supported syndication formats!</p>" | ||
"XML Parser Output:<br /><div class='xmlparseroutput'>")); | ||
g_string_append (feed->parseErrors, "</div>"); | ||
} else if (!ctxt->feed->fhp) { | ||
/* There's a feed but no handler. This means autodiscovery | ||
* found a feed, but we still need to download it. | ||
* An update should be in progress that will process it */ | ||
} else { | ||
/* Feed found, process it */ | ||
itemSetPtr itemSet; | ||
|
||
node->available = TRUE; | ||
|
||
/* merge the resulting items into the node's item set */ | ||
itemSet = node_get_itemset (node); | ||
node->newCount = itemset_merge_items (itemSet, ctxt->items, ctxt->feed->valid, ctxt->feed->markAsRead); | ||
if (node->newCount) | ||
itemlist_merge_itemset (itemSet); | ||
itemset_free (itemSet); | ||
|
||
/* restore user defined properties if necessary */ | ||
if ((flags & FEED_REQ_RESET_TITLE) && ctxt->title) | ||
node_set_title (node, ctxt->title); | ||
|
||
if (flags > 0) | ||
db_subscription_update (subscription); | ||
} | ||
ctxt = feed_parser_ctxt_new (subscription, result->data, result->size); | ||
|
||
feed_free_parser_ctxt (ctxt); | ||
} else { | ||
/* try to parse the feed */ | ||
if (!feed_parse (ctxt)) { | ||
/* No feed found, display an error */ | ||
node->available = FALSE; | ||
|
||
} else if (!ctxt->feed->fhp) { | ||
/* There's a feed but no handler. This means autodiscovery | ||
* found a feed, but we still need to download it. | ||
* An update should be in progress that will process it */ | ||
} else { | ||
/* Feed found, process it */ | ||
itemSetPtr itemSet; | ||
|
||
node->available = TRUE; | ||
|
||
/* merge the resulting items into the node's item set */ | ||
itemSet = node_get_itemset (node); | ||
node->newCount = itemset_merge_items (itemSet, ctxt->items, ctxt->feed->valid, ctxt->feed->markAsRead); | ||
if (node->newCount) | ||
itemlist_merge_itemset (itemSet); | ||
itemset_free (itemSet); | ||
|
||
/* restore user defined properties if necessary */ | ||
if ((flags & FEED_REQ_RESET_TITLE) && ctxt->title) | ||
node_set_title (node, ctxt->title); | ||
|
||
// FIXME: this duplicates the db_subscription_update() in subscription.c | ||
if (flags > 0) | ||
db_subscription_update (subscription); | ||
} | ||
|
||
feed_list_view_update_node (node->id); | ||
feed_parser_ctxt_free (ctxt); | ||
|
||
// FIXME: this should not be here, but in subscription.c | ||
if (FETCH_ERROR_NONE != subscription->error) { | ||
node->available = FALSE; | ||
liferea_shell_set_status_bar (_("\"%s\" is not available"), node_get_title (node)); | ||
} else { | ||
liferea_shell_set_status_bar (_("\"%s\" updated..."), node_get_title (node)); | ||
} | ||
|
||
debug_exit ("feed_process_update_result"); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
/** | ||
* @file feed.h common feed handling interface | ||
* | ||
* Copyright (C) 2003-2017 Lars Windolf <[email protected]> | ||
* | ||
* Copyright (C) 2003-2021 Lars Windolf <[email protected]> | ||
* Copyright (C) 2004-2006 Nathan J. Conrad <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
|
@@ -31,15 +31,15 @@ | |
/* | ||
* The feed concept in Liferea comprises several standalone concepts: | ||
* | ||
* 1.) A "feed" is an XML document to be parsed | ||
* 1.) A "feed" is an XML/XML-like document to be parsed | ||
* (-> see feed_parser.h) | ||
* | ||
* 2.) A "feed" is a node in the feed list. | ||
* 2.) A "feed" is a node type that is visible in the feed list. | ||
* | ||
* 3.) A "feed" is a way of updating a subscription. | ||
* 3.) A "feed" is a subscription type: a way of updating. | ||
* | ||
* The feed.h interface provides default methods for 2.) and 3.) that | ||
* are used per-default but might be overwritten by node source, node | ||
* The feed.h interface provides default methods for 2.) and 3.) that | ||
* are used per-default but might be overwritten by node source, node | ||
* type or subscription type specific implementations. | ||
*/ | ||
|
||
|
@@ -49,10 +49,10 @@ typedef struct feed { | |
|
||
/* feed cache state properties */ | ||
gint cacheLimit; /**< Amount of cache to save: See the cache_limit enum */ | ||
|
||
/* feed parsing state */ | ||
gboolean valid; /**< FALSE if there was an error in xml_parse_feed() */ | ||
GString *parseErrors; /**< textual description of parsing errors */ | ||
GString *parseErrors; /**< Detailed textual description of parsing errors (e.g. library error handler output) */ | ||
gint64 time; /**< Feeds modified date */ | ||
|
||
/* feed specific behaviour settings */ | ||
|
@@ -76,15 +76,15 @@ feedPtr feed_new(void); | |
* @param feedNode XML node to add feed attributes to, | ||
* or NULL if a new XML document is to | ||
* be created | ||
* | ||
* | ||
* @returns a new XML document (if feedNode was NULL) | ||
*/ | ||
xmlDocPtr feed_to_xml(nodePtr node, xmlNodePtr xml); | ||
|
||
// FIXME: doesn't seem to belong here (looks like a subscription type method) | ||
/** | ||
* Returns the feed-specific maximum cache size. | ||
* If none is set it returns the global default | ||
* If none is set it returns the global default | ||
* setting. | ||
* | ||
* @param node the feed node | ||
|
Oops, something went wrong.