diff options
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 |