diff options
author | lnu <lnu@f70e237a-67f3-0310-a06c-d2b8a7116972> | 2006-10-23 16:30:31 +0000 |
---|---|---|
committer | lnu <lnu@f70e237a-67f3-0310-a06c-d2b8a7116972> | 2006-10-23 16:30:31 +0000 |
commit | 58be214e8ea62bf16d64161cf71079ee6e553816 (patch) | |
tree | 14a25a6eb09e977b6d283e0431201675c02a3833 /lib/feed2imap | |
parent | a29f5e3c95a4f038b67b0e5467a2099765959aaf (diff) | |
download | feed2imap-58be214e8ea62bf16d64161cf71079ee6e553816.tar.gz feed2imap-58be214e8ea62bf16d64161cf71079ee6e553816.tar.bz2 feed2imap-58be214e8ea62bf16d64161cf71079ee6e553816.zip |
adding parse failures
git-svn-id: svn+ssh://svn.gna.org/svn/feed2imap/trunk/feed2imap@107 f70e237a-67f3-0310-a06c-d2b8a7116972
Diffstat (limited to '')
-rw-r--r-- | lib/feed2imap/cache.rb | 16 | ||||
-rw-r--r-- | lib/feed2imap/feed2imap.rb | 8 |
2 files changed, 22 insertions, 2 deletions
diff --git a/lib/feed2imap/cache.rb b/lib/feed2imap/cache.rb index 4687b76..00e6951 100644 --- a/lib/feed2imap/cache.rb +++ b/lib/feed2imap/cache.rb @@ -40,6 +40,7 @@ class ItemCache puts "GET_NEW_ITEMS FOR #{id}... (#{Time::now})" end @channels[id] ||= CachedChannel::new + @channels[id].parsefailures = 0 return @channels[id].get_new_items(items, always_new, ignore_hash) end @@ -69,6 +70,12 @@ class ItemCache @channels[id].fetch_failed end + # Parsing failure. + # returns number of failures + def parse_failed(id) + @channels[id].parse_failed + end + # Load the cache from an IO stream def load(io) begin @@ -110,7 +117,7 @@ class CachedChannel # 100 items should be enough for everybody, even quite busy feeds CACHESIZE = 100 - attr_accessor :lastcheck, :items, :failures + attr_accessor :lastcheck, :items, :failures, :parsefailures def initialize @lastcheck = Time::at(0) @@ -118,6 +125,7 @@ class CachedChannel @itemstemp = [] # see below @nbnewitems = 0 @failures = 0 + @parsefailures = 0 end # Let's explain @items and @itemstemp. @@ -234,6 +242,12 @@ class CachedChannel @items.length end + def parse_failed + @parsefailures = 0 if @parsefailures.nil? + @parsefailures += 1 + return @parsefailures + end + def fetch_failed @failures = 0 if @failures.nil? @failures += 1 diff --git a/lib/feed2imap/feed2imap.rb b/lib/feed2imap/feed2imap.rb index 2f62a80..7d67f8d 100644 --- a/lib/feed2imap/feed2imap.rb +++ b/lib/feed2imap/feed2imap.rb @@ -182,7 +182,13 @@ class Feed2Imap begin feed = FeedParser::Feed::new(f.body) rescue Exception => e - @logger.fatal("Error while parsing #{f.name}: #{e}") + n = @cache.parse_failed(feed.name) + m = "Error while parsing #{f.name}: #{e} (failed #{n} times)" + if n > @config.max_failures + @logger.fatal(m) + else + @logger.info(m) + end next end begin |