diff options
Diffstat (limited to '')
-rw-r--r-- | lib/feed2imap/config.rb | 17 | ||||
-rw-r--r-- | lib/feed2imap/feed2imap.rb | 2 | ||||
-rw-r--r-- | lib/feed2imap/imap.rb | 5 |
3 files changed, 16 insertions, 8 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 diff --git a/lib/feed2imap/feed2imap.rb b/lib/feed2imap/feed2imap.rb index fb4c794..b938a39 100644 --- a/lib/feed2imap/feed2imap.rb +++ b/lib/feed2imap/feed2imap.rb @@ -247,7 +247,7 @@ class Feed2Imap id = "<#{fn}-#{i.cacheditem.index}@#{@config.hostname}>" email = item_to_mail(@config, i, id, true, f.name, f.include_images, f.wrapto) f.imapaccount.updatemail(f.folder, email, - id, i.date || Time::new) + id, i.date || Time::new, f.reupload_if_updated) end # reverse is needed to upload older items first (fixes gna#8986) newitems.reverse.each do |i| diff --git a/lib/feed2imap/imap.rb b/lib/feed2imap/imap.rb index c4e7106..60775e2 100644 --- a/lib/feed2imap/imap.rb +++ b/lib/feed2imap/imap.rb @@ -108,7 +108,7 @@ class ImapAccount end # update a mail - def updatemail(folder, mail, id, date = Time::now) + def updatemail(folder, mail, id, date = Time::now, reupload_if_updated = true) create_folder_if_not_exists(folder) @connection.select(folder) searchres = @connection.search(['HEADER', 'Message-Id', id]) @@ -119,6 +119,9 @@ class ImapAccount searchres.each { |m| @connection.store(m, "+FLAGS", [:Deleted]) } @connection.expunge flags -= [ :Recent ] # avoids errors with dovecot + elsif not reupload_if_updated + # mail not present, and we don't want to re-upload it + return end @connection.append(folder, mail.gsub(/\n/, "\r\n"), flags, date) end |