def retrieve(repo)
      errorlen = errors.size
      unless repo.kind_of?(::RightScraper::Repositories::Base)
        repo = ::RightSupport::Data::Mash.new(repo)
        repository_hash = repo.delete(:repository_hash)  # optional
        repo = RightScraper::Repositories::Base.from_hash(repo)
        if repository_hash && repository_hash != repo.repository_hash
          raise RightScraper::Error, "Repository hash mismatch: #{repository_hash} != #{repo.repository_hash}"
        end
      end

      retriever = nil

      # 1. Retrieve the files
      @logger.operation(:retrieving, "from #{repo}") do
        # note that the retriever type may be unavailable but allow the
        # retrieve method to raise any such error.
        retriever = repo.retriever(@options)
        retriever.retrieve
      end

      if errors.size == errorlen
        # create the freed directory with world-writable permission for
        # subsequent scan output for less-privileged child processes.
        freed_base_path = freed_dir(repo)
        ::FileUtils.rm_rf(freed_base_path) if ::File.exist?(freed_base_path)
        ::FileUtils.mkdir_p(freed_base_path)
        ::File.chmod(0777, freed_base_path)

        # the following hash is needed for running any subsequent scanners.
        {
          ignorable_paths: retriever.ignorable_paths,
          repo_dir: retriever.repo_dir,
          freed_dir: freed_base_path,
          repository: retriever.repository
        }
      else
        nil
      end
    end
def retrieve(repo)
      errorlen = errors.size
      unless repo.kind_of?(::RightScraper::Repositories::Base)
        repo = ::RightSupport::Data::Mash.new(repo)
        repository_hash = repo.delete(:repository_hash)  # optional
        repo = RightScraper::Repositories::Base.from_hash(repo)
        if repository_hash && repository_hash != repo.repository_hash
          raise RightScraper::Error, "Repository hash mismatch: #{repository_hash} != #{repo.repository_hash}"
        end
      end

      retriever = nil

      # 1. Retrieve the files
      @logger.operation(:retrieving, "from #{repo}") do
        # note that the retriever type may be unavailable but allow the
        # retrieve method to raise any such error.
        retriever = repo.retriever(@options)
        retriever.retrieve
      end

      if errors.size == errorlen
        # create the freed directory with world-writable permission for
        # subsequent scan output for less-privileged child processes.
        freed_base_path = freed_dir(repo)
        ::FileUtils.rm_rf(freed_base_path) if ::File.exist?(freed_base_path)
        ::FileUtils.mkdir_p(freed_base_path)
        ::File.chmod(0777, freed_base_path)

        # the following hash is needed for running any subsequent scanners.
        {
          ignorable_paths: retriever.ignorable_paths,
          repo_dir: retriever.repo_dir,
          freed_dir: freed_base_path,
          repository: retriever.repository
        }
      else
        nil
      end
    end
Retrieves the given repository. See #scrape for details.