summaryrefslogtreecommitdiff
path: root/lib/feed2imap/cache.rb
diff options
context:
space:
mode:
authorlnu <lnu@f70e237a-67f3-0310-a06c-d2b8a7116972>2006-10-23 16:30:31 +0000
committerlnu <lnu@f70e237a-67f3-0310-a06c-d2b8a7116972>2006-10-23 16:30:31 +0000
commit58be214e8ea62bf16d64161cf71079ee6e553816 (patch)
tree14a25a6eb09e977b6d283e0431201675c02a3833 /lib/feed2imap/cache.rb
parenta29f5e3c95a4f038b67b0e5467a2099765959aaf (diff)
downloadfeed2imap-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.rb16
1 files changed, 15 insertions, 1 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