Class: PodCacheValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-binary-cache/prebuild_cache.rb

Class Method Summary collapse

Class Method Details

.verify_devpod_checksum(sandbox_root, generated_framework_path, lock_file) ⇒ Object

Cache miss/hit checking for development pods Return 2 Hashes for cache miss and cache hit libraries



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/cocoapods-binary-cache/prebuild_cache.rb', line 12

def self.verify_devpod_checksum(sandbox_root, generated_framework_path, lock_file)
  devpod_path = "#{sandbox_root}/devpod/"
  target_path = generated_framework_path
  Pod::UI.puts "verify_devpod_checksum: #{devpod_path}"
  external_sources = lock_file.to_hash["EXTERNAL SOURCES"]
  unless File.directory?(target_path)
    FileUtils.mkdir_p(target_path)
  end
  missing_pods_dic = Hash[]
  cachehit_pods_dic = Hash[]
  if !external_sources
    Pod::UI.puts 'No development pods!'
    return missing_pods_dic, cachehit_pods
  end
  external_sources.each do |name, attribs|
    if attribs.class == Hash
      path = attribs[:path]
      if path
        hash = FolderChecksum.checksum(path)
        cached_path = "#{devpod_path}#{name}_#{hash}"
        if !Dir.exists?(cached_path)
          missing_pods_dic[name] = hash
        else
          cachehit_pods_dic[name] = hash
          target_dir = "#{target_path}/#{name}"
          FileUtils.rm_r(target_dir, :force => true)
          FileUtils.cp_r(cached_path, target_dir)
        end
      end
    else
      Pod::UI.puts "Error, wrong type: #{attribs}"
    end
  end
  return missing_pods_dic, cachehit_pods_dic
end