summaryrefslogtreecommitdiff
path: root/lib/feed2imap/feed2imap.rb
diff options
context:
space:
mode:
authorlnu <lnu@f70e237a-67f3-0310-a06c-d2b8a7116972>2005-04-05 14:49:46 +0000
committerlnu <lnu@f70e237a-67f3-0310-a06c-d2b8a7116972>2005-04-05 14:49:46 +0000
commitdb22b5125675e8eaf90bc1651fb20d5d5f48e02a (patch)
treef1d4725b537ba49938ff5ed3dc0cd0d5ac28d9a5 /lib/feed2imap/feed2imap.rb
parentedd60fa2d3c972932da7be1605fec2674069c31b (diff)
downloadfeed2imap-db22b5125675e8eaf90bc1651fb20d5d5f48e02a.tar.gz
feed2imap-db22b5125675e8eaf90bc1651fb20d5d5f48e02a.tar.bz2
feed2imap-db22b5125675e8eaf90bc1651fb20d5d5f48e02a.zip
git-svn-id: svn+ssh://svn.gna.org/svn/feed2imap/trunk/feed2imap@12 f70e237a-67f3-0310-a06c-d2b8a7116972
Diffstat (limited to 'lib/feed2imap/feed2imap.rb')
-rw-r--r--lib/feed2imap/feed2imap.rb35
1 files changed, 21 insertions, 14 deletions
diff --git a/lib/feed2imap/feed2imap.rb b/lib/feed2imap/feed2imap.rb
index 3131587..9896a3c 100644
--- a/lib/feed2imap/feed2imap.rb
+++ b/lib/feed2imap/feed2imap.rb
@@ -24,6 +24,7 @@ require 'feed2imap/cache'
require 'feed2imap/channel'
require 'feed2imap/httpfetcher'
require 'logger'
+require 'thread'
# Feed2Imap version
F2I_VERSION = '0.2'
@@ -81,23 +82,29 @@ class Feed2Imap
end
# for each feed, fetch, upload to IMAP and cache
@logger.info("Fetching feeds")
+ loggermon = Mutex::new
+ ths = []
@config.feeds.each do |f|
- @logger.info("Processing #{f.name}")
- begin
- f.body = HTTPFetcher::fetch(f.url, @cache.get_last_check(f.name))
- # dump if requested
- if @config.dumpdir
- fname = @config.dumpdir + '/' + f.name + '-' + Time::now.xmlschema
- File::open(fname, 'w') { |file| file.puts f.body }
+ ths << Thread::new do
+ begin
+ f.body = HTTPFetcher::fetch(f.url, @cache.get_last_check(f.name))
+ # dump if requested
+ if @config.dumpdir
+ fname = @config.dumpdir + '/' + f.name + '-' + Time::now.xmlschema
+ File::open(fname, 'w') { |file| file.puts f.body }
+ end
+ rescue Timeout::Error
+ loggermon.synchronize do
+ @logger.fatal("Timeout::Error while fetching #{f.url}: #{$!}")
+ end
+ rescue
+ loggermon.synchronize do
+ @logger.fatal("Error while fetching #{f.url}: #{$!}")
+ end
end
- rescue Timeout::Error
- @logger.fatal("Timeout::Error while fetching #{f.url}: #{$!}")
- next
- rescue
- @logger.fatal("Error while fetching #{f.url}: #{$!}")
- next
end
end
+ ths.each { |t| t.join }
@logger.info("Parsing and uploading")
@config.feeds.each do |f|
next if f.body.nil? # means 304
@@ -114,7 +121,7 @@ class Feed2Imap
puts $!.backtrace
next
end
- @logger.info("#{newitems.length} new items, #{updateditems.length} updated items.") if newitems.length > 0 or updateditems.length > 0
+ @logger.info("#{f.name}: #{newitems.length} new items, #{updateditems.length} updated items.") if newitems.length > 0 or updateditems.length > 0
begin
if !cacherebuild
updateditems.each { |i| f.imapaccount.updatemail(f.folder, i.to_mail(f.name), i.cacheditem.index) }
ogmsg'> 2017-12-18Quote array specifierJason A. Donenfeld1-1/+1 Otherwise this expands to a filename if one exists. Suggested-by: izaberina@gmail.com 2017-10-13protect dirname calls from pass-names that look like command-line optionsStacey Sheldon1-6/+6 With the $path variable being passed directly to dirname, any pass-names provided by the user that happened to look like options to dirname would be processed as options rather than as the path to be split. This results in a real mess when you happen to run one of: pass edit --help pass generate --help pass insert --help then in the cmd_foo() function, you have: mkdir -p -v "$PREFIX/$(dirname --help)" which (due to the -p option to mkdir) results in the creation of an entire directory hierarchy made up of the slash-separated help text from dirname. 2017-09-15passmenu: Don't eat whitespace at beginning/end of passwordDaniel Lublin1-1/+1 If IFS (Input Field Separator) is not emptied, read will actually strip spaces and tabs at the beginning/end end of the "line". 2017-08-29emacs: Release version 1.0.1 of Emacs packageSvend Sorensen2-5/+10 2017-08-29emacs: --run-async: Quote shell argumentsDamien Cassou1-4/+5 This is important for filenames with special characters such as spaces and parenthesis. 2017-08-29emacs: Update author's email addressSvend Sorensen1-2/+2 2017-08-29emacs: Fix package-lint violationsSvend Sorensen1-2/+3 2017-07-26emacs: Release version 1.0.0 of Emacs packageSvend Sorensen2-1/+8 2017-07-26emacs: Use with-editor to wrap "pass edit"Svend Sorensen2-9/+17 Instead of editing the password file directly using Emacs, "pass edit" is run. This allows password-store's git change tracking to work. This adds a dependency on the with-editor Emacs package. 2017-04-13Bump version1.7.1Jason A. Donenfeld1-1/+1 2017-04-13init: match only the public keyJason A. Donenfeld1-1/+1 2017-03-28Use $GPG variableJason A. Donenfeld1-3/+3 2017-03-20Fix compatibility with GnuPG 2.2.19Andreas Stieger2-2/+2 GnuPG 2.2.19 added a warning when no command was given. * src/password-store.sh (reencrypt_path): Add --decrypt to --list-only * tests/t0300-reencryption.sh (gpg_keys_from_encrypted_file): same https://bugs.gnupg.org/gnupg/msg9873 http://git.gnupg.org/cgi-bin/gitweb.cgi?p=gnupg.git;a=commit;h=810adfd47801fc01e45fb71af9f05c91f7890cdb https://bugzilla.suse.com/show_bug.cgi?id=1028867 2017-03-01tests: fix on OSX by not using the tr hackJason A. Donenfeld3-5/+2 2017-02-26Bump version1.7Jason A. Donenfeld1-1/+1 2017-02-26Modernize makefileJason A. Donenfeld2-31/+36 2017-02-25CopyrightJason A. Donenfeld1-1/+1 2017-02-25StyleJason A. Donenfeld1-2/+2 2017-02-25git: use inner-most directoryJason A. Donenfeld2-27/+48 2017-02-25clip: sleep may require argv[0] to be sleepJason A. Donenfeld1-1/+1 2017-02-25man: document system extensionsJason A. Donenfeld1-2/+3