diff options
Diffstat (limited to 'lib/feed2imap')
-rw-r--r-- | lib/feed2imap/config.rb | 3 | ||||
-rw-r--r-- | lib/feed2imap/feed2imap.rb | 9 |
2 files changed, 11 insertions, 1 deletions
diff --git a/lib/feed2imap/config.rb b/lib/feed2imap/config.rb index 3aea4bb..4c3a858 100644 --- a/lib/feed2imap/config.rb +++ b/lib/feed2imap/config.rb @@ -72,7 +72,7 @@ end # A configured feed. simple data container. class ConfigFeed - attr_reader :name, :url, :imapaccount, :folder, :always_new, :execurl, :filter, :ignore_hash + attr_reader :name, :url, :imapaccount, :folder, :always_new, :execurl, :filter, :ignore_hash, :dumpdir attr_accessor :body def initialize(f, imapaccount, folder) @@ -86,6 +86,7 @@ class ConfigFeed @filter = f['filter'] @ignore_hash = f['ignore-hash'] || false @freq = @freq.to_i if @freq + @dumpdir = f['dumpdir'] || nil end def needfetch(lastcheck) diff --git a/lib/feed2imap/feed2imap.rb b/lib/feed2imap/feed2imap.rb index a2474be..fcb483e 100644 --- a/lib/feed2imap/feed2imap.rb +++ b/lib/feed2imap/feed2imap.rb @@ -149,6 +149,15 @@ class Feed2Imap end end end + # dump this feed if requested + if feed.dumpdir + mutex.synchronize do + if feed.body + fname = feed.dumpdir + '/' + feed.name + '-' + Time::now.xmlschema + File::open(fname, 'w') { |file| file.puts feed.body } + end + end + end rescue Timeout::Error mutex.synchronize do n = @cache.fetch_failed(feed.name) |