diff options
author | Alex Legler <alex@a3li.li> | 2015-02-23 15:21:27 +0100 |
---|---|---|
committer | Alex Legler <alex@a3li.li> | 2015-02-23 15:21:27 +0100 |
commit | 2a13f18aa0a7ac3fe7d19eeea45842de818a615c (patch) | |
tree | c67b09ac642018550f2ca203851c87dc3ccadc33 /ag | |
parent | Implement --delete (diff) | |
download | backend-2a13f18aa0a7ac3fe7d19eeea45842de818a615c.tar.gz backend-2a13f18aa0a7ac3fe7d19eeea45842de818a615c.tar.bz2 backend-2a13f18aa0a7ac3fe7d19eeea45842de818a615c.zip |
use more threads!
Diffstat (limited to 'ag')
-rwxr-xr-x | ag | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -7,6 +7,8 @@ require 'mail' require 'maildir' require 'elasticsearch' require 'optparse' +require 'parallel' +require 'ruby-progressbar' require_relative 'lib/utils' require_relative 'lib/threading' require_relative 'lib/rendering' @@ -111,7 +113,9 @@ $es.transport.reload_connections! def do_full Ag::Storage.create_index($options.name) - $maildir.list(:cur).each do |maildir_message| + messages = $maildir.list(:cur) + + Parallel.each(messages, progress: "Importing #{$options.name}") do |maildir_message| mail = maildir_message.data begin @@ -126,14 +130,16 @@ def do_full end def do_incremental - $maildir.list(:new).each do |maildir_message| + messages = $maildir.list(:cur) + + Parallel.each(messages, progress: "Importing #{$options.name}") do |maildir_message| mail = maildir_message.data begin Ag::Storage.store($options.name, mail, maildir_message.filename) maildir_message.process unless $options.readonly rescue => e - $stderr.puts "Cannot save message #{mail.message_id} (file #{maildir_message.filename}): #{e.message}" + $stderr.puts "Cannot save message #{mail.message_id} (file #{maildir_message.filename}): #{e.message}" if $options.debug next end end |