Skip to content
This repository has been archived by the owner on Dec 22, 2019. It is now read-only.

Commit

Permalink
Only update feed when new notifications exist
Browse files Browse the repository at this point in the history
  • Loading branch information
cn committed Nov 13, 2011
1 parent 8bdfb8e commit 92442cf
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/wcc-rss-notificator.rb
Expand Up @@ -10,6 +10,7 @@ class RSSNotificator
# TODO: can we hook into --clean?

def initialize(opts)
@dirty = false
if opts.is_a?(Hash)
@file = opts['file'] || WCC::Conf.file("atom.xml")
@db_name = opts['db_name']
Expand Down Expand Up @@ -63,6 +64,7 @@ def notify!(data)
id = "#{@feed['id']}item/#{Time.now.to_f}"

# append entries to class variable (not thread safe)
@dirty = true
feed = get_feeddb['feed']
feed.insert 0, {
'title' => title,
Expand All @@ -75,6 +77,8 @@ def notify!(data)
end

def shut_down
return unless @dirty

WCC.logger.debug "Writing feed-db '#{@db_name}' to file"

feeddb_file = WCC::Conf.file("feed-db-#{@db_name}.yml")
Expand Down

0 comments on commit 92442cf

Please sign in to comment.