lib/omnibus/digestable.rb
def digest_directory(path, type = :md5, options = {})
      digest = digest_from_type(type)
      log.info(log_key) { "Digesting #{path} with #{type}" }
      FileSyncer.all_files_under(path, options).each do |filename|
        # Calculate the filename relative to the given path. Since directories
        # are SHAed according to their filepath, two difference directories on
        # disk would have different SHAs even if they had the same content.
        relative = Pathname.new(filename).relative_path_from(Pathname.new(path))

        case ftype = File.ftype(filename)
        when "file"
          update_with_string(digest, "#{ftype} #{relative}")
          update_with_file_contents(digest, filename)
        else
          update_with_string(digest, "#{ftype} #{relative}")
        end
      end

      digest.hexdigest
    end
def digest_directory(path, type = :md5, options = {})
      digest = digest_from_type(type)
      log.info(log_key) { "Digesting #{path} with #{type}" }
      FileSyncer.all_files_under(path, options).each do |filename|
        # Calculate the filename relative to the given path. Since directories
        # are SHAed according to their filepath, two difference directories on
        # disk would have different SHAs even if they had the same content.
        relative = Pathname.new(filename).relative_path_from(Pathname.new(path))

        case ftype = File.ftype(filename)
        when "file"
          update_with_string(digest, "#{ftype} #{relative}")
          update_with_file_contents(digest, filename)
        else
          update_with_string(digest, "#{ftype} #{relative}")
        end
      end

      digest.hexdigest
    end
Calculate the digest of a directory at the given path. Each file in the
 directory is read in binary chunks to prevent excess memory usage.
 Filesystem entries of all types are included in the digest, including
 directories, links, and sockets. The contents of non-file entries are
 represented as:

   $type $path

 while the contents of regular files are represented as:

   file $path

 and then appended by the binary contents of the file/

 @param [String] path
   the path of the directory to digest
 @param [Symbol] type
   the type of digest to use
 @param [Hash] options
   options to pass through to the FileSyncer when scanning for files

 @return [String]
   the hexdigest of the directory