Skip to content

Commit

Permalink
Detect existing URLs on feed redirection (bug 1457)
Browse files Browse the repository at this point in the history
When the feed is redirected, we usually simply rewrite
the URL. However, if the new URL already exists in the
subscriptions, we must not allow this, and ideally
fail to update the feed to avoid duplicates.
  • Loading branch information
thp committed Nov 12, 2011
1 parent 1b0dc1a commit d02368d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/gpodder/gtkui/main.py
Expand Up @@ -2093,14 +2093,16 @@ def add_podcast_list(self, urls, auth_tokens=None):
if auth_tokens is None:
auth_tokens = {}

existing_urls = set(podcast.url for podcast in self.channels)

# Sort and split the URL list into five buckets
queued, failed, existing, worked, authreq = [], [], [], [], []
for input_url in urls:
url = util.normalize_feed_url(input_url)
if url is None:
# Fail this one because the URL is not valid
failed.append(input_url)
elif self.podcast_list_model.get_filter_path_from_url(url) is not None:
elif url in existing_urls:
# A podcast already exists in the list for this URL
existing.append(url)
else:
Expand Down
2 changes: 2 additions & 0 deletions src/gpodder/model.py
Expand Up @@ -1091,6 +1091,8 @@ def update(self, max_episodes=0, mimetype_prefs=''):
except feedcore.NewLocation, updated:
feed = updated.data
logger.info('New feed location: %s => %s', self.url, feed.href)
if feed.href in set(x.url for x in self.model.get_podcasts()):
raise Exception('Already subscribed to ' + feed.href)
self.url = feed.href
self._consume_updated_feed(feed, max_episodes, mimetype_prefs)
self._update_etag_modified(feed)
Expand Down

0 comments on commit d02368d

Please sign in to comment.