[Commits] [SCM] claws branch, master, updated. 3.17.0-162-ge725cc0

ticho at claws-mail.org ticho at claws-mail.org
Tue Nov 13 21:42:15 CET 2018


The branch, master has been updated
       via  e725cc0f9d8fc64f896977c786b016b56d15d087 (commit)
      from  a2fe3fd40f7c275ff7dc67a581d6361dcbee730a (commit)

Summary of changes:
 src/plugins/rssyl/rssyl.c             |    6 +++-
 src/plugins/rssyl/rssyl_add_item.c    |    2 +-
 src/plugins/rssyl/rssyl_deleted.c     |   63 +++++++++++++++++----------------
 src/plugins/rssyl/rssyl_deleted.h     |    7 ++--
 src/plugins/rssyl/rssyl_parse_feed.c  |    5 +--
 src/plugins/rssyl/rssyl_update_feed.c |    3 ++
 6 files changed, 49 insertions(+), 37 deletions(-)


- Log -----------------------------------------------------------------
commit e725cc0f9d8fc64f896977c786b016b56d15d087
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Tue Nov 13 21:41:04 2018 +0100

    Use much less disk IO when working with .deleted files in RSSyl.

diff --git a/src/plugins/rssyl/rssyl.c b/src/plugins/rssyl/rssyl.c
index b246a74..a4f39fb 100644
--- a/src/plugins/rssyl/rssyl.c
+++ b/src/plugins/rssyl/rssyl.c
@@ -831,6 +831,7 @@ static gint rssyl_remove_msg(Folder *folder, FolderItem *item, gint num)
 {
 	gboolean need_scan = FALSE;
 	gchar *file, *tmp;
+	RFolderItem *ritem = (RFolderItem *)item;
 
 	g_return_val_if_fail(item != NULL, -1);
 
@@ -849,7 +850,10 @@ static gint rssyl_remove_msg(Folder *folder, FolderItem *item, gint num)
 	}
 	g_free(tmp);
 
-	rssyl_deleted_add((RFolderItem *)item, file);
+	rssyl_deleted_update(ritem);
+	rssyl_deleted_add(ritem, file);
+	rssyl_deleted_store(ritem);
+	rssyl_deleted_free(ritem);
 
 	if( g_unlink(file) < 0 ) {
 		FILE_OP_ERROR(file, "unlink");
diff --git a/src/plugins/rssyl/rssyl_add_item.c b/src/plugins/rssyl/rssyl_add_item.c
index 5e74276..5897d25 100644
--- a/src/plugins/rssyl/rssyl_add_item.c
+++ b/src/plugins/rssyl/rssyl_add_item.c
@@ -388,7 +388,7 @@ void rssyl_add_item(RFolderItem *ritem, FeedItem *feed_item)
 	}
 
 	/* Check against list of deleted items. */
-	if (rssyl_deleted_check(ritem->deleted_items, feed_item)) {
+	if (rssyl_deleted_check(ritem, feed_item)) {
 		debug_print("RSSyl: Item '%s' found among deleted items, NOT adding it.\n",
 				feed_item_get_title(feed_item));
 		return;
diff --git a/src/plugins/rssyl/rssyl_deleted.c b/src/plugins/rssyl/rssyl_deleted.c
index 4a7569a..23fac15 100644
--- a/src/plugins/rssyl/rssyl_deleted.c
+++ b/src/plugins/rssyl/rssyl_deleted.c
@@ -61,13 +61,15 @@ static void _free_deleted_item(gpointer d, gpointer user_data)
 	g_free(ditem);
 }
 
-void rssyl_deleted_free(GSList *deleted_items)
+void rssyl_deleted_free(RFolderItem *ritem)
 {
-	if (deleted_items != NULL) {
+	cm_return_if_fail(ritem != NULL);
+
+	if (ritem->deleted_items != NULL) {
 		debug_print("RSSyl: releasing list of deleted items\n");
-		g_slist_foreach(deleted_items, _free_deleted_item, NULL);
-		g_slist_free(deleted_items);
-		deleted_items = NULL;
+		g_slist_foreach(ritem->deleted_items, _free_deleted_item, NULL);
+		g_slist_free(ritem->deleted_items);
+		ritem->deleted_items = NULL;
 	}
 }
 
@@ -83,7 +85,7 @@ static gchar * _deleted_file_path(RFolderItem *ritem)
 }
 
 /***************************************************************/
-GSList *rssyl_deleted_update(RFolderItem *ritem)
+void rssyl_deleted_update(RFolderItem *ritem)
 {
 	gchar *deleted_file, *contents, **lines, **line;
 	GError *error = NULL;
@@ -91,16 +93,16 @@ GSList *rssyl_deleted_update(RFolderItem *ritem)
 	RDeletedItem *ditem = NULL;
 	GSList *deleted_items = NULL;
 
-	g_return_val_if_fail(ritem != NULL, NULL);
+	g_return_if_fail(ritem != NULL);
 
 	deleted_file = _deleted_file_path(ritem);
 
-	debug_print("RSSyl: getting list of deleted items from '%s'\n", deleted_file);
+	debug_print("RSSyl: (DELETED) getting list of deleted items from '%s'\n", deleted_file);
 
 	if (!g_file_test(deleted_file, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
 		debug_print("RSSyl: '%s' doesn't exist, ignoring\n", deleted_file);
 		g_free(deleted_file);
-		return NULL;
+		return;
 	}
 
 	g_file_get_contents(deleted_file, &contents, NULL, &error);
@@ -115,7 +117,7 @@ GSList *rssyl_deleted_update(RFolderItem *ritem)
 	} else {
 		g_warning("Couldn't read '%s', ignoring", deleted_file);
 		g_free(deleted_file);
-		return NULL;
+		return;
 	}
 
 	g_free(deleted_file);
@@ -143,7 +145,9 @@ GSList *rssyl_deleted_update(RFolderItem *ritem)
 	g_free(contents);
 
 	debug_print("RSSyl: got %d deleted items\n", g_slist_length(deleted_items));
-	return deleted_items;
+
+	rssyl_deleted_free(ritem);
+	ritem->deleted_items = deleted_items;
 }
 
 static void _store_one_deleted_item(gpointer data, gpointer user_data)
@@ -211,8 +215,11 @@ void rssyl_deleted_add(RFolderItem *ritem, gchar *path)
 {
 	FeedItem *fitem = NULL;
 	RDeletedItem *ditem = NULL;
-	GSList *deleted_items = rssyl_deleted_update(ritem);
-	gchar *deleted_file = NULL;
+
+	cm_return_if_fail(ritem != NULL);
+	cm_return_if_fail(path != NULL);
+
+	debug_print("RSSyl: (DELETED) add\n");
 
 	if (!(fitem = rssyl_parse_folder_item_file(path)))
 		return;
@@ -223,13 +230,7 @@ void rssyl_deleted_add(RFolderItem *ritem, gchar *path)
 			CS_UTF_8, FALSE);
 	ditem->date_published = feed_item_get_date_published(fitem);
 
-	deleted_items = g_slist_prepend(deleted_items, ditem);
-
-	deleted_file = _deleted_file_path(ritem);
-	rssyl_deleted_store_internal(deleted_items, deleted_file);
-	g_free(deleted_file);
-
-	rssyl_deleted_free(deleted_items);
+	ritem->deleted_items = g_slist_prepend(ritem->deleted_items, ditem);
 
 	RFeedCtx *ctx = (RFeedCtx *)fitem->data;
 	g_free(ctx->path);
@@ -279,11 +280,19 @@ static gint _rssyl_deleted_check_func(gconstpointer a, gconstpointer b)
 }
 
 /* Returns TRUE if fitem is found among the deleted stuff. */
-gboolean rssyl_deleted_check(GSList *deleted_items, FeedItem *fitem)
+gboolean rssyl_deleted_check(RFolderItem *ritem, FeedItem *fitem)
 {
-	if (g_slist_find_custom(deleted_items, (gconstpointer)fitem,
-				_rssyl_deleted_check_func) != NULL)
+	cm_return_val_if_fail(ritem != NULL, FALSE);
+	cm_return_val_if_fail(fitem != NULL, FALSE);
+
+	debug_print("RSSyl: (DELETED) check\n");
+	rssyl_deleted_update(ritem);
+	if (g_slist_find_custom(ritem->deleted_items, (gconstpointer)fitem,
+				_rssyl_deleted_check_func) != NULL) {
+		rssyl_deleted_free(ritem);
 		return TRUE;
+	}
+	rssyl_deleted_free(ritem);
 
 	return FALSE;
 }
@@ -343,7 +352,7 @@ void rssyl_deleted_expire(RFolderItem *ritem, Feed *feed)
 	g_return_if_fail(ritem != NULL);
 	g_return_if_fail(feed != NULL);
 
-	ritem->deleted_items = rssyl_deleted_update(ritem);
+	debug_print("RSSyl: (DELETED) expire\n");
 
 	/* Iterate over all items in the list */
 	d = ritem->deleted_items;
@@ -369,10 +378,4 @@ void rssyl_deleted_expire(RFolderItem *ritem, Feed *feed)
 
 		g_free(ctx);
 	}
-
-	/* Write the new list to disk */
-	rssyl_deleted_store(ritem);
-
-	/* And clean up after myself */
-	rssyl_deleted_free(ritem->deleted_items);
 }
diff --git a/src/plugins/rssyl/rssyl_deleted.h b/src/plugins/rssyl/rssyl_deleted.h
index d3c198d..d0f76df 100644
--- a/src/plugins/rssyl/rssyl_deleted.h
+++ b/src/plugins/rssyl/rssyl_deleted.h
@@ -5,10 +5,11 @@
 
 #include "rssyl.h"
 
-GSList *rssyl_deleted_update(RFolderItem *ritem);
-void *rssyl_deleted_free(GSList *deleted_items);
+void rssyl_deleted_update(RFolderItem *ritem);
+void rssyl_deleted_free(RFolderItem *ritem);
 void rssyl_deleted_add(RFolderItem *ritem, gchar *path);
-gboolean rssyl_deleted_check(GSList *deleted_items, FeedItem *fitem);
+void rssyl_deleted_store(RFolderItem *ritem);
+gboolean rssyl_deleted_check(RFolderItem *ritem, FeedItem *fitem);
 void rssyl_deleted_expire(RFolderItem *ritem, Feed *feed);
 
 #endif /* __RSSYL_DELETED_H */
diff --git a/src/plugins/rssyl/rssyl_parse_feed.c b/src/plugins/rssyl/rssyl_parse_feed.c
index 265001b..616e798 100644
--- a/src/plugins/rssyl/rssyl_parse_feed.c
+++ b/src/plugins/rssyl/rssyl_parse_feed.c
@@ -211,7 +211,7 @@ gboolean rssyl_parse_feed(RFolderItem *ritem, Feed *feed)
 
 	/* Populate the ->deleted_items list so that we can check it when
 	 * adding each item. */
-	ritem->deleted_items = rssyl_deleted_update(ritem);
+	rssyl_deleted_update(ritem);
 
 	/* Parse each item in the feed, adding or updating existing items if
 	 * necessary */
@@ -223,7 +223,8 @@ gboolean rssyl_parse_feed(RFolderItem *ritem, Feed *feed)
 		rssyl_expire_items(ritem, feed);
 	}
 
-	rssyl_deleted_free(ritem->deleted_items);
+	/* Clean up ->deleted_items */
+	rssyl_deleted_free(ritem);
 
 	folder_item_scan(&ritem->item);
 	folder_item_update_thaw();
diff --git a/src/plugins/rssyl/rssyl_update_feed.c b/src/plugins/rssyl/rssyl_update_feed.c
index d85288d..2e6645d 100644
--- a/src/plugins/rssyl/rssyl_update_feed.c
+++ b/src/plugins/rssyl/rssyl_update_feed.c
@@ -291,7 +291,10 @@ gboolean rssyl_update_feed(RFolderItem *ritem, RSSylVerboseFlags verbose)
 
 	/* Prune our deleted items list of items which are no longer in
 	 * upstream feed. */
+	rssyl_deleted_update(ritem);
 	rssyl_deleted_expire(ritem, ctx->feed);
+	rssyl_deleted_store(ritem);
+	rssyl_deleted_free(ritem);
 
 	/* Clean up. */
 	success = ctx->success;

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


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list