From f609f6fd98f447bdb9fc3cf06b03a2aa177df4b5 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Sun, 20 Jan 2013 09:54:33 +0100 Subject: Test if the MongoDB collection exist before the creation. --- source/feedgetter.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'source') diff --git a/source/feedgetter.py b/source/feedgetter.py index b6b5e8b6..82ad2a0f 100755 --- a/source/feedgetter.py +++ b/source/feedgetter.py @@ -108,16 +108,16 @@ class FeedGetter(object): sha1_hash.update(feed_link.encode('utf-8')) feed_id = sha1_hash.hexdigest() - collection_dic = {"feed_id": feed_id, \ - "type": 0, \ - "feed_image": feed_image, \ - "feed_title": utils.clear_string(a_feed.feed.title), \ - "feed_link": feed_link, \ - "site_link": a_feed.feed.link, \ - "mail": False \ - } - - self.articles.add_collection(collection_dic) + if None == self.articles.get_feed(feed_id): + collection_dic = {"feed_id": feed_id, \ + "type": 0, \ + "feed_image": feed_image, \ + "feed_title": utils.clear_string(a_feed.feed.title), \ + "feed_link": feed_link, \ + "site_link": a_feed.feed.link, \ + "mail": False \ + } + self.articles.add_collection(collection_dic) articles = [] for article in a_feed['entries']: -- cgit