Sha256: 333a35700206f5fb7d8f852d9142585d02272dfe5187d857a3e9c172b5388d66
Contents?: true
Size: 1.56 KB
Versions: 70
Compression:
Stored size: 1.56 KB
Contents
require 'digest' # Resolves the chicken-and-egg problem with md5 checksums. The handlers need # to reference files with the md5 checksum. The files are the: # # jets/code/rack-checksum.zip # jets/code/opt-checksum.zip # # We compute the checksums before we generate the node shim handlers. class Jets::Builders class Md5 class << self @@checksums = {} def checksums @@checksums end def stage_folders paths = [] paths << "stage/opt" if folder_exist?("opt") paths << "stage/rack" if folder_exist?("rack") # Important to have stage/code at the end, since its md5 checksum depends # on the previous folders. paths << "stage/code" paths end def folder_exist?(folder) path = "#{Jets.build_root}/stage/#{folder}" File.directory?(path) end def compute! stage_folders.each do |path| @@checksums[path] = dir(path) end @@checksums end def dir(short_path) path = "#{Jets.build_root}/#{short_path}" files = Dir["#{path}/**/*"] files.reject! { |f| File.directory?(f) } .reject! { |f| File.symlink?(f) } content = files.map do |f| Digest::MD5.file(f).to_s[0..7] end.join # The stage/code md5 sha depends on the other 'symlinked' folders. if short_path == "stage/code" content += @@checksums.values.join end md5 = Digest::MD5.new md5.update(content) md5.hexdigest.to_s[0..7] end end end end
Version data entries
70 entries across 70 versions & 2 rubygems