diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-11-23 07:44:05 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-11-23 07:44:05 +0200 |
commit | f9346b83551f95f9e32f963c0574540f2805eb23 (patch) | |
tree | 16ea286e638e90965580b371e2021db424a187c8 /src/feeds.c | |
parent | de40f34076fc2f7d2170c4b3d017ab18d2f0d0a1 (diff) |
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.
Diffstat (limited to 'src/feeds.c')
-rw-r--r-- | src/feeds.c | 10 |
1 files changed, 10 insertions, 0 deletions
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 | |||
386 | setUrlKept_Visited(visited_App(), &entry->url, iTrue); | 386 | setUrlKept_Visited(visited_App(), &entry->url, iTrue); |
387 | } | 387 | } |
388 | } | 388 | } |
389 | iStringSet *handledUrls = new_StringSet(); | ||
389 | lock_Mutex(d->mtx); | 390 | lock_Mutex(d->mtx); |
390 | iForEach(PtrArray, i, incoming) { | 391 | iForEach(PtrArray, i, incoming) { |
391 | iFeedEntry *entry = i.ptr; | 392 | iFeedEntry *entry = i.ptr; |
392 | size_t pos; | 393 | size_t pos; |
394 | if (contains_StringSet(handledUrls, &entry->url)) { | ||
395 | /* This is a duplicate. Each unique URL is handled only once. */ | ||
396 | delete_FeedEntry(entry); | ||
397 | remove_PtrArrayIterator(&i); | ||
398 | continue; | ||
399 | } | ||
400 | insert_StringSet(handledUrls, &entry->url); | ||
393 | if (locate_SortedArray(&d->entries, &entry, &pos)) { | 401 | if (locate_SortedArray(&d->entries, &entry, &pos)) { |
394 | iFeedEntry *existing = *(iFeedEntry **) at_SortedArray(&d->entries, pos); | 402 | iFeedEntry *existing = *(iFeedEntry **) at_SortedArray(&d->entries, pos); |
395 | iAssert(!isHeadingEntry_FeedEntry_(existing)); | 403 | iAssert(!isHeadingEntry_FeedEntry_(existing)); |
@@ -422,6 +430,8 @@ static iBool updateEntries_Feeds_(iFeeds *d, iBool isHeadings, uint32_t sourceId | |||
422 | remove_PtrArrayIterator(&i); | 430 | remove_PtrArrayIterator(&i); |
423 | } | 431 | } |
424 | unlock_Mutex(d->mtx); | 432 | unlock_Mutex(d->mtx); |
433 | fflush(stdout); | ||
434 | iRelease(handledUrls); | ||
425 | } | 435 | } |
426 | return gotNew; | 436 | return gotNew; |
427 | } | 437 | } |