From f9346b83551f95f9e32f963c0574540f2805eb23 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Tue, 23 Nov 2021 07:44:05 +0200 Subject: Feeds: Fixed handlig of duplicate entries Feed entries are expected to have unique URLs, since the URL is the identifier of an entry. If a feed has the same URL for more than one entry, only process the first one and ignore the rest. An entry will still show up as unread if it keeps the same URL but changes its title. --- src/feeds.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/feeds.c') diff --git a/src/feeds.c b/src/feeds.c index baec6870..26b3d6db 100644 --- a/src/feeds.c +++ b/src/feeds.c @@ -386,10 +386,18 @@ static iBool updateEntries_Feeds_(iFeeds *d, iBool isHeadings, uint32_t sourceId setUrlKept_Visited(visited_App(), &entry->url, iTrue); } } + iStringSet *handledUrls = new_StringSet(); lock_Mutex(d->mtx); iForEach(PtrArray, i, incoming) { iFeedEntry *entry = i.ptr; size_t pos; + if (contains_StringSet(handledUrls, &entry->url)) { + /* This is a duplicate. Each unique URL is handled only once. */ + delete_FeedEntry(entry); + remove_PtrArrayIterator(&i); + continue; + } + insert_StringSet(handledUrls, &entry->url); if (locate_SortedArray(&d->entries, &entry, &pos)) { iFeedEntry *existing = *(iFeedEntry **) at_SortedArray(&d->entries, pos); iAssert(!isHeadingEntry_FeedEntry_(existing)); @@ -422,6 +430,8 @@ static iBool updateEntries_Feeds_(iFeeds *d, iBool isHeadings, uint32_t sourceId remove_PtrArrayIterator(&i); } unlock_Mutex(d->mtx); + fflush(stdout); + iRelease(handledUrls); } return gotNew; } -- cgit v1.2.3