From: Michael Orlitzky Date: Sun, 13 Jun 2010 15:51:41 +0000 (-0400) Subject: Only enumerate accounts in domains whose folders exist. X-Git-Tag: 0.0.1~144 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=d0b14082e76120df31457fa3791a1dd374157b3d;p=mailshears.git Only enumerate accounts in domains whose folders exist. --- diff --git a/src/dovecot_mailstore.rb b/src/dovecot_mailstore.rb index a794032..81eb167 100644 --- a/src/dovecot_mailstore.rb +++ b/src/dovecot_mailstore.rb @@ -13,10 +13,16 @@ class DovecotMailstore < Mailstore domains.each do |domain| domain_path = File.join(@domain_root, domain) - usernames = Filesystem.get_subdirs(domain_path) - usernames.each do |username| - accounts << "#{username}@#{domain}" + if File.directory?(domain_path) + # If domain_path isn't a directory, maybe the + # domain folder doesn't exist? In that case, I + # guess we want to report zero accounts. + usernames = Filesystem.get_subdirs(domain_path) + + usernames.each do |username| + accounts << "#{username}@#{domain}" + end end end