Skip to content
This repository has been archived by the owner on Nov 27, 2018. It is now read-only.

Commit

Permalink
Bump listen to 2.2.0 and fix subsequent bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
titanous committed Nov 18, 2013
1 parent 65938dd commit deb07b1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
5 changes: 3 additions & 2 deletions lib/mailman/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,16 @@ def run
if config.watch_maildir
require 'listen'
Mailman.logger.debug "Monitoring the Maildir for new messages..."
base = Pathname.new(@maildir.path)

callback = Proc.new do |modified, added, removed|
added.each do |new_file|
message = Maildir::Message.new(@maildir, "new/#{new_file}")
message = Maildir::Message.new(@maildir, Pathname.new(new_file).relative_path_from(base).to_s)
@processor.process_maildir_message(message)
end
end

@listener = Listen::Listener.new(File.join(@maildir.path, 'new'), :relative_paths => true, &callback)
@listener = Listen::Listener.new(File.join(@maildir.path, 'new'), &callback)
@listener.start
sleep
end
Expand Down
2 changes: 1 addition & 1 deletion mailman.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Gem::Specification.new do |s|

s.add_dependency 'mail', '>= 2.0.3'
s.add_dependency 'activesupport', '>= 2.3.4'
s.add_dependency 'listen', '~> 1.3.1'
s.add_dependency 'listen', '~> 2.2.0'
s.add_dependency 'maildir', '>= 0.5.0'
s.add_dependency 'i18n', '>= 0.4.1' # fix for mail/activesupport-3 dependency issue

Expand Down
12 changes: 5 additions & 7 deletions spec/functional/application_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
after do
Mailman.reset_config!
listener = @app.instance_variable_get('@listener')
listener.stop unless listener.nil?
begin
listener.stop unless listener.nil?
rescue SystemExit # eat listen exit
end
end

def send_example
Expand Down Expand Up @@ -200,12 +203,7 @@ def send_example
FileUtils.cp(File.join(SPEC_ROOT, 'fixtures', 'example01.eml'), test_message_path) # copy a message into place, triggering listen handler
FileUtils.cp(File.join(SPEC_ROOT, 'fixtures', 'example01.eml'), test_message_path_3) # copy a message into place, triggering listen handler
sleep(0.5)
begin
Timeout::timeout(THREAD_TIMING) {
app_thread.join
}
rescue Timeout::Error # wait for listen handler
end
app_thread.kill
@app.router.instance_variable_get('@count').should == 3

FileUtils.rm_rf(config.maildir)
Expand Down

0 comments on commit deb07b1

Please sign in to comment.