Method: Concrete::FileCacheMap#loadData

Defined in:
lib/concrete/file_cache_map.rb

#loadData(keyPath) ⇒ Object

load data associated with file keyPath returns :invalid in case either the associated file or the cache file has changed



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/concrete/file_cache_map.rb', line 27

def loadData(keyPath)
  cf = cacheFile(keyPath)
  return :invalid unless File.exist?(cf)
  result = nil
  File.open(cf, "rb") do |f|
    checksum = f.read(41)[0..39]
    data = f.read
    if calcSha1(data) == checksum
      if calcSha1(keyData(keyPath)) == data[0..39]
        result = data[41..-1]
      else
        result = :invalid
      end
    else
      result = :invalid
    end
  end 
  result
end