From 58be214e8ea62bf16d64161cf71079ee6e553816 Mon Sep 17 00:00:00 2001 From: lnu Date: Mon, 23 Oct 2006 16:30:31 +0000 Subject: adding parse failures git-svn-id: svn+ssh://svn.gna.org/svn/feed2imap/trunk/feed2imap@107 f70e237a-67f3-0310-a06c-d2b8a7116972 --- lib/feed2imap/cache.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'lib/feed2imap/cache.rb') 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 -- cgit v1.2.3-70-g09d2