Package: newsbeuter / 2.9-8

15-dont-skip-ignored.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
Description: Fix a bug that skipped items while checking against ignore rules
Origin: upstream, https://github.com/akrennmair/newsbeuter/commit/ffc376b13f10e92721cda7ab17cdbd2966f7e251
Bug: https://github.com/akrennmair/newsbeuter/issues/269

--- a/include/rss.h
+++ b/include/rss.h
@@ -220,6 +220,12 @@
 			items_.push_back(item);
 			items_guid_map[item->guid()] = item;
 		}
+		inline void set_items(std::vector<std::shared_ptr<rss_item>>& items) {
+			erase_items(items_.begin(), items_.end());
+			for (auto item : items) {
+				add_item(item);
+			}
+		}
 
 		inline void clear_items() {
 			LOG(LOG_DEBUG, "rss_feed: clearing items");
--- a/src/cache.cpp
+++ b/src/cache.cpp
@@ -447,29 +447,20 @@
 		throw dbexception(db);
 	}
 
-	unsigned int i=0;
-	for (auto it=feed->items().begin(); it != feed->items().end(); ++it,++i) {
-		(*it)->set_cache(this);
-		(*it)->set_feedptr(feed);
-		(*it)->set_feedurl(feed->rssurl());
-
+	std::vector<std::shared_ptr<rss_item>> filtered_items;
+	for (auto item : feed->items()) {
 		try {
-			if (ign && ign->matches(it->get())) {
-				feed->erase_item(it);
-				// since we modified the vector, we need to reset the iterator
-				// to the beginning of the vector, and then fast-forward to
-				// the next element.
-				it = feed->items().begin();
-				--i;
-				for (int j=0; j<int(i); j++) {
-					++it;
-				}
-				continue;
+			if (!ign || (ign && ! ign->matches(item.get()))) {
+				item->set_cache(this);
+				item->set_feedptr(feed);
+				item->set_feedurl(feed->rssurl());
+				filtered_items.push_back(item);
 			}
 		} catch(const matcherexception& ex) {
 			LOG(LOG_DEBUG, "oops, matcher exception: %s", ex.what());
 		}
 	}
+	feed->set_items(filtered_items);
 
 	unsigned int max_items = cfg->get_configvalue_as_int("max-items");