Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
Index: lib/rubygems/source_info_cache.rb =================================================================== --- lib/rubygems/source_info_cache.rb (revision 1423) +++ lib/rubygems/source_info_cache.rb (working copy) @@ -74,24 +74,38 @@ @cache_data = Marshal.load data @cache_data.each do |url, sice| - next unless Hash === sice + next unless sice.is_a?(Hash) @dirty = true - if sice.key? 'cache' and sice.key? 'size' and - Gem::SourceIndex === sice['cache'] and Numeric === sice['size'] then - new_sice = Gem::SourceInfoCacheEntry.new sice['cache'], sice['size'] + cache = sice['cache'] + size = sice['size'] + if cache.is_a?(Gem::SourceIndex) and size.is_a?(Numeric) then + new_sice = Gem::SourceInfoCacheEntry.new cache, size @cache_data[url] = new_sice else # irreperable, force refetch. - sice = Gem::SourceInfoCacheEntry.new Gem::SourceIndex.new, 0 - sice.refresh url # HACK may be unnecessary, see ::cache and #refresh - @cache_data[url] = sice + reset_cache_data(url) end end @cache_data - rescue - {} + rescue => ex + if Gem.configuration.really_verbose + say "Exception during cache_data handling: #{ex.class} - #{ex}" + say "Cache file was: #{cache_file}" + end + reset_cache_data end end + def reset_cache_data(url = nil) + if url + sice = Gem::SourceInfoCacheEntry.new Gem::SourceIndex.new, 0 + sice.refresh url # HACK may be unnecessary, see ::cache and #refresh + @cache_data[url] = sice + else + @cache_data = {} + end + @cache_data + end + # The name of the cache file to be read def cache_file return @cache_file if @cache_file
This paste will be private.
From the Design Piracy series on my blog: