class Envirobly::Aws::S3

def pull(object_tree_checksum, target_dir)

def pull(object_tree_checksum, target_dir)
  puts "Pulling #{object_tree_checksum} into #{target_dir}"
  manifest = fetch_manifest(object_tree_checksum)
  FileUtils.mkdir_p(target_dir)
  puts "Downloading #{manifest.size} files"
  pool = Concurrent::FixedThreadPool.new(CONCURRENCY)
  manifest.each do |(mode, type, object_hash, path)|
    pool.post do
      target_path = File.join target_dir, path
      if mode == Envirobly::Git::Commit::SYMLINK_FILE_MODE
        fetch_symlink(object_hash, target_path:)
      else
        fetch_object(object_hash, target_path:)
        if mode == Envirobly::Git::Commit::EXECUTABLE_FILE_MODE
          FileUtils.chmod("+x", target_path)
        end
      end
    end
  end
  pool.shutdown
  pool.wait_for_termination
end