diff --git a/lib/qasim/config.rb b/lib/qasim/config.rb index 451c2c8..94a68a8 100644 --- a/lib/qasim/config.rb +++ b/lib/qasim/config.rb @@ -4,7 +4,6 @@ require 'ostruct' require 'pp' require 'find' -#require 'rdebug/base' require 'qasim' module Qasim @@ -15,8 +14,6 @@ module Qasim attr_reader :mnt_dir def initialize - - @mnt_dir = File.join ENV['HOME'], "mnt" @config_dir = APP_CONFIG_DIR @@ -30,27 +27,26 @@ module Qasim end def parse_maps &blk - #rdebug "Config: #{@config_dir}/config" - @maps = [] map_dirs = [@config_dir, APP_SYSCONFIG_DIR].select{ |d| File.exist? d and File.directory? d } + Find.find( *map_dirs ) do |path| - if File.file? path - if File.basename( path ) =~ /.map$/ - begin - map = Map.new self, path - yield map if block_given? - maps.push map - rescue - # error while parsing map - end - end - #total_size += FileTest.size(path) + # Skip unwanted files fast + next unless File.file? path + next unless File.basename( path ) =~ /.map$/ + + begin + map = Map.new self, path + yield map if block_given? + maps.push map + rescue + raise RuntimeError, "Error while parsing map file" end end end end end +