recover from, and warn when, .rsconscache loads something other than a Hash

This commit is contained in:
Josh Holtrop 2013-09-19 16:18:07 -04:00
parent 9b954d9d98
commit 45a0d56c54

View File

@ -61,6 +61,10 @@ module Rscons
# file.
def initialize
@cache = YAML.load(File.read(CACHE_FILE)) rescue {}
unless @cache.is_a?(Hash)
$stderr.puts "Warning: #{CACHE_FILE} was corrupt. Contents:\n#{@cache.inspect}"
@cache = {}
end
@cache[:targets] ||= {}
@cache[:directories] ||= {}
@cache[:version] ||= VERSION