Skip to content

Commit

Permalink
Don't try to store status updates for fake blog entries
Browse files Browse the repository at this point in the history
We create fake entries when scanning for saved blogs, and they should
never be saved to the db.

This was broken by baefbd4 which pushed
the save into the aggregator. Now, make it optional.
  • Loading branch information
mhagander committed Feb 11, 2016
1 parent 2471326 commit 409bcb3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion hamnadmin/hamnadmin/register/forms.py
Expand Up @@ -29,7 +29,7 @@ def _trace(msg):

# Create a fake instance to pass down. We'll just throw it away
feedobj = Blog(feedurl=self.cleaned_data['feedurl'], authorfilter=self.cleaned_data['authorfilter'])
fetcher = FeedFetcher(feedobj, _trace)
fetcher = FeedFetcher(feedobj, _trace, False)
try:
entries = list(fetcher.parse())
except Exception, e:
Expand Down
10 changes: 6 additions & 4 deletions hamnadmin/hamnadmin/util/aggregate.py
Expand Up @@ -7,9 +7,10 @@
from hamnadmin.register.models import Post

class FeedFetcher(object):
def __init__(self, feed, tracefunc=None):
def __init__(self, feed, tracefunc=None, update=True):
self.feed = feed
self.tracefunc = tracefunc
self.update = update
self.newest_entry_date = None

def _trace(self, msg):
Expand Down Expand Up @@ -104,12 +105,13 @@ def parse(self, fetchsince=None):
# currently define rediculously long as 5 days
d = datetime.datetime.now()

self.feed.lastget = d
self.feed.save()
if self.update:
self.feed.lastget = d
self.feed.save()
else:
# We didn't get a Last-Modified time, so set it to the entry date
# for the latest entry in this feed.
if self.newest_entry_date:
if self.newest_entry_date and self.update:
self.feed.lastget = self.newest_entry_date
self.feed.save()

Expand Down

0 comments on commit 409bcb3

Please sign in to comment.