Permalink
Browse files

Don't choke if tmp has unparseable JSON (or non-JSON)

  • Loading branch information...
1 parent 47036ac commit b3b2067766a93a11138244f03e7ab4187aa01781 @wagenet wagenet committed Sep 15, 2010
Showing with 5 additions and 1 deletion.
  1. +5 −1 lib/sproutcore/models/target.rb
@@ -346,7 +346,11 @@ def file_attr(attr_name, path, &block)
# read cache from disk if needed
if @file_attr_cache.nil? && File.exists?(file_attr_cache_path)
- @file_attr_cache = JSON.parse File.read(file_attr_cache_path)
+ begin
+ @file_attr_cache = JSON.parse File.read(file_attr_cache_path)
+ rescue JSON::ParserError
+ # Unparseable, will be handled by the following conditional
+ end
# Sometimes the file is corrupted, in this case, clear the cache
File.delete file_attr_cache_path unless @file_attr_cache

0 comments on commit b3b2067

Please sign in to comment.