Method: Inspec::CachedFetcher#assert_cache_sanity!

Defined in:
lib/inspec/cached_fetcher.rb

#assert_cache_sanity!Object



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/inspec/cached_fetcher.rb', line 87

def assert_cache_sanity!
  # do not check cache sanity if the target is a gem or a resource pack
  # which are known by a special prefix on their cache key or by having the :gem key
  return if target.respond_to?(:key?) && target.key?(:gem)
  return unless target.respond_to?(:key?) && target.key?(:sha256)

  exception_message = "    The remote source \#{fetcher} no longer has the requested content:\n\n    Request Content Hash: \#{target[:sha256]}\n    Actual Content Hash: \#{fetcher.resolved_source[:sha256]}\n\n    For URL, supermarket, compliance, and other sources that do not\n    provide versioned artifacts, this likely means that the remote source\n    has changed since your lockfile was generated.\n  EOF\n  raise exception_message if fetcher.resolved_source[:sha256] != target[:sha256]\nend\n"