tab: return default values on existing, blank install receipt contents.

This commit is contained in:
Mike McQuaid 2021-01-14 16:26:17 +00:00
parent 128aeba3a4
commit eaae52edb8
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70

View File

@ -58,7 +58,12 @@ class Tab < OpenStruct
# Returns the {Tab} for an install receipt at `path`.
# Results are cached.
def self.from_file(path)
cache.fetch(path) { |p| cache[p] = from_file_content(File.read(p), p) }
cache.fetch(path) do |p|
content = File.read(p)
return empty if content.blank?
cache[p] = from_file_content(content, p)
end
end
# Like {from_file}, but bypass the cache.