[Commits] [SCM] claws branch, master, updated. 3.10.1-104-gbf3f91d

ticho at claws-mail.org ticho at claws-mail.org
Wed Jun 25 22:59:59 CEST 2014


The branch master of project "claws" (Claws Mail) has been updated
       via  bf3f91d9ce21acf3fd52ed6ad4c25a956f1490aa (commit)
      from  96dbb8027447a57c613507f5d4f98b3973a3ddae (commit)

Summary of changes:
 src/plugins/rssyl/rssyl_add_item.c      |    2 --
 src/plugins/rssyl/rssyl_parse_feed.c    |   32 +++++++++++++++++++++++++++++--
 src/plugins/rssyl/rssyl_update_format.c |    1 -
 3 files changed, 30 insertions(+), 5 deletions(-)


- Log -----------------------------------------------------------------
commit bf3f91d9ce21acf3fd52ed6ad4c25a956f1490aa
Author: Andrej Kacian <andrej at kacian.sk>
Date:   Wed Jun 25 22:59:35 2014 +0200

    RSSyl: handle expiring comments after their parent is gone

diff --git a/src/plugins/rssyl/rssyl_add_item.c b/src/plugins/rssyl/rssyl_add_item.c
index 54020af..50a5102 100644
--- a/src/plugins/rssyl/rssyl_add_item.c
+++ b/src/plugins/rssyl/rssyl_add_item.c
@@ -285,8 +285,6 @@ void rssyl_add_item(RFolderItem *ritem, FeedItem *feed_item)
 	g_return_if_fail(ritem != NULL);
 
 	/* If item title is empty, try to fill it from source title (Atom only). */
-	debug_print(",%s,\n", (feed_item->title ? feed_item->title : "<null>"));
-	debug_print(",%s,\n", (feed_item->sourcetitle ? feed_item->sourcetitle : "<null>"));
 	tmp = feed_item_get_sourcetitle(feed_item);
 	if( feed_item_get_title(feed_item) == NULL ||
 			strlen(feed_item->title) == 0 ) {
diff --git a/src/plugins/rssyl/rssyl_parse_feed.c b/src/plugins/rssyl/rssyl_parse_feed.c
index 88dc406..37c2ba0 100644
--- a/src/plugins/rssyl/rssyl_parse_feed.c
+++ b/src/plugins/rssyl/rssyl_parse_feed.c
@@ -55,6 +55,7 @@ static void rssyl_foreach_parse_func(gpointer data, gpointer user_data)
 struct _RSSylExpireItemsCtx {
 	gboolean exists;
 	FeedItem *item;
+	GSList *expired_ids;
 };
 
 typedef struct _RSSylExpireItemsCtx RSSylExpireItemsCtx;
@@ -96,27 +97,54 @@ static void rssyl_expire_items(RFolderItem *ritem, Feed *feed)
 	g_return_if_fail(feed != NULL);
 
 	ctx = malloc( sizeof(RSSylExpireItemsCtx) );
+	ctx->expired_ids = NULL;
 
 	/* Check each locally stored item, if it is still in the upstream
 	 * feed - xnay it if not. */
 	for( i = ritem->items; i != NULL; i = i->next ) {
 		item = (FeedItem *)i->data;
 
-		/* Do not expire comments, they expire with their parents */
+		/* Comments will be expired later, once we know which parent items
+		 * have been expired. */
 		if (feed_item_get_parent_id(item) != NULL)
 			continue;
 
+		/* Find matching item in the fresh feed. */
 		ctx->exists = FALSE;
 		ctx->item = item;
 		feed_foreach_item(feed, expire_items_func, ctx);
 
 		if( !ctx->exists ) {
+			/* No match, add item ids to the list and get rid of it. */
+			debug_print("RSSyl: expiring '%s'\n", feed_item_get_id(item));
+			ctx->expired_ids = g_slist_prepend(ctx->expired_ids,
+					g_strdup(feed_item_get_id(item)));
 			fctx = (RFeedCtx *)item->data;
-			/* TODO: expire item's comments (items with our parent_id) */
 			g_remove(fctx->path);
 		}
 	}
 
+	/* Now do one more pass over folder contents, and expire comments
+	 * whose parents are gone. */
+	for( i = ritem->items; i != NULL; i = i->next ) {
+		item = (FeedItem *)i->data;
+
+		/* Handle comments expiration. */
+		if (feed_item_get_parent_id(item) != NULL) {
+			/* If its parent's id is on list of expired ids, this comment
+			 * can go as well. */
+			if (g_slist_find_custom(ctx->expired_ids,
+					feed_item_get_parent_id(item), (GCompareFunc)g_strcmp0)) {
+				debug_print("RSSyl: expiring comment '%s'\n", feed_item_get_id(item));
+				fctx = (RFeedCtx *)item->data;
+				g_remove(fctx->path);
+			}
+		}
+	}
+
+	debug_print("RSSyl: expired %d items\n", g_slist_length(ctx->expired_ids));
+
+	g_slist_free_full(ctx->expired_ids, g_free);
 	g_free(ctx);
 }
 
diff --git a/src/plugins/rssyl/rssyl_update_format.c b/src/plugins/rssyl/rssyl_update_format.c
index 323da20..35fe172 100644
--- a/src/plugins/rssyl/rssyl_update_format.c
+++ b/src/plugins/rssyl/rssyl_update_format.c
@@ -152,7 +152,6 @@ static void rssyl_update_format_func(FolderItem *item, gpointer data)
 
 			rssyl_feed_start_refresh_timeout(ritem);
 
-			/* TODO: copy feed preferences from old structure */
 			ritem->official_title = g_strdup(of->official_name);
 			ritem->default_refresh_interval =
 				(of->default_refresh_interval != 0 ? TRUE : FALSE);

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list