summaryrefslogtreecommitdiff
path: root/lib/feed2imap/config.rb
diff options
context:
space:
mode:
authorLucas Nussbaum <lucas@lucas-nussbaum.net>2010-11-30 22:03:03 +0100
committerLucas Nussbaum <lucas@lucas-nussbaum.net>2010-11-30 22:03:03 +0100
commitc46c823aff3ad63fbc62c2281ac4fddb0bcb1e21 (patch)
tree13952d711e7a96ab1580c84a595c04dce89b4134 /lib/feed2imap/config.rb
parent94dc1db641f98242496a32409e823920f4e700e9 (diff)
downloadfeed2imap-c46c823aff3ad63fbc62c2281ac4fddb0bcb1e21.tar.gz
feed2imap-c46c823aff3ad63fbc62c2281ac4fddb0bcb1e21.tar.bz2
feed2imap-c46c823aff3ad63fbc62c2281ac4fddb0bcb1e21.zip
Add a reupload_if_updated option (default: true)
Following a discussion on feed2imap-devel, add a reupload_if_updated option. When set to false, if an item is updated, but was previously removed from the IMAP server, it is no longer re-uploaded. Also fix some config file parsing bugs for the disable-ssl-verification and include-images options. I should really switch to another way to describe F2I config...
Diffstat (limited to '')
-rw-r--r--lib/feed2imap/config.rb17
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/feed2imap/config.rb b/lib/feed2imap/config.rb
index 53e6543..c0cdddd 100644
--- a/lib/feed2imap/config.rb
+++ b/lib/feed2imap/config.rb
@@ -33,7 +33,7 @@ LOGNAME = Etc.getlogin
# Feed2imap configuration
class F2IConfig
- attr_reader :imap_accounts, :cache, :feeds, :dumpdir, :updateddebug, :max_failures, :include_images, :default_email, :hostname
+ attr_reader :imap_accounts, :cache, :feeds, :dumpdir, :updateddebug, :max_failures, :include_images, :default_email, :hostname, :reupload_if_updated
# Load the configuration from the IO stream
# TODO should do some sanity check on the data read.
@@ -45,9 +45,10 @@ class F2IConfig
@feeds = []
@max_failures = (@conf['max-failures'] || 10).to_i
@updateddebug = (@conf['debug-updated'] and @conf['debug-updated'] != 'false')
- @include_images = (@conf['include-images'] and @conf['include-images'] != 'false')
+ @include_images = !(@conf.has_key?('include-images') and @conf['include-images'] != 'false')
+ @reupload_if_updated = !(@conf.has_key?('reupload-if-updated') and @conf['reupload-if-updated'] == false)
@default_email = (@conf['default-email'] || "#{LOGNAME}@#{HOSTNAME}")
- ImapAccount.no_ssl_verify = (@conf['disable-ssl-verification'] and @conf['disable-ssl-verification'] != 'false')
+ ImapAccount.no_ssl_verify = (@conf.has_key?('disable-ssl-verification') and @conf['disable-ssl-verification'] == true)
@hostname = HOSTNAME # FIXME: should this be configurable as well?
@imap_accounts = ImapAccounts::new
maildir_account = MaildirAccount::new
@@ -94,7 +95,7 @@ end
# A configured feed. simple data container.
class ConfigFeed
- attr_reader :name, :url, :imapaccount, :folder, :always_new, :execurl, :filter, :ignore_hash, :dumpdir, :wrapto, :include_images
+ attr_reader :name, :url, :imapaccount, :folder, :always_new, :execurl, :filter, :ignore_hash, :dumpdir, :wrapto, :include_images, :reupload_if_updated
attr_accessor :body
def initialize(f, imapaccount, folder, f2iconfig)
@@ -111,8 +112,12 @@ class ConfigFeed
@dumpdir = f['dumpdir'] || nil
@wrapto = if f['wrapto'] == nil then 72 else f['wrapto'].to_i end
@include_images = f2iconfig.include_images
- if f['include-images']
- @include_images = (f['include-images'] != 'false')
+ if f.has_key?('include-images')
+ @include_images = (f['include-images'] != false)
+ end
+ @reupload_if_updated = f2iconfig.reupload_if_updated
+ if f.has_key?('reupload-if-updated')
+ @reupload_if_updated = (f['reupload-if-updated'] != false)
end
end