From 45a0d56c548b80c35ee6d9ef5064537fd25bf5be Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Thu, 19 Sep 2013 16:18:07 -0400 Subject: [PATCH] recover from, and warn when, .rsconscache loads something other than a Hash --- lib/rscons/cache.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/rscons/cache.rb b/lib/rscons/cache.rb index dc94a7f..f927fae 100644 --- a/lib/rscons/cache.rb +++ b/lib/rscons/cache.rb @@ -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