<commit_before>package coursier

import java.net.{HttpURLConnection, URL}
import java.nio.channels.{ OverlappingFileLockException, FileLock }
import java.security.MessageDigest
import java.util.concurrent.{ConcurrentHashMap, Executors, ExecutorService}

import scala.annotation.tailrec
import scalaz._
import scalaz.concurrent.{ Task, Strategy }

import java.io.{ Serializable => _, _ }

object Cache {

  def withLocal(artifact: Artifact, cache: Seq[(String, File)]): Artifact = {
    def local(url: String) =
      if (url.startsWith("file:///"))
        url.stripPrefix("file://")
      else if (url.startsWith("file:/"))
        url.stripPrefix("file:")
      else {
        val localPathOpt = cache.collectFirst {
          case (base, cacheDir) if url.startsWith(base) =>
            cacheDir + "/" + url.stripPrefix(base)
        }

        localPathOpt.getOrElse {
          // FIXME Means we were handed an artifact from repositories other than the known ones
          println(cache.mkString("\n"))
          println(url)
          ???
        }
      }

    if (artifact.extra.contains("local"))
      artifact
    else
      artifact.copy(extra = artifact.extra + ("local" ->
        artifact.copy(
          url = local(artifact.url),
          checksumUrls = artifact.checksumUrls
            .mapValues(local)
            .toVector
            .toMap,
          extra = Map.empty
        )
      ))
  }

  def download(
    artifact: Artifact,
    cache: Seq[(String, File)],
    checksums: Set[String],
    cachePolicy: CachePolicy,
    pool: ExecutorService,
    logger: Option[Logger] = None
  ): Task[Seq[((File, String), FileError \/ Unit)]] = {

    implicit val pool0 = pool
<commit_msg>Make private methods that should be<commit_after>package coursier

import java.net.{HttpURLConnection, URL}
import java.nio.channels.{ OverlappingFileLockException, FileLock }
import java.security.MessageDigest
import java.util.concurrent.{ConcurrentHashMap, Executors, ExecutorService}

import scala.annotation.tailrec
import scalaz._
import scalaz.concurrent.{ Task, Strategy }

import java.io.{ Serializable => _, _ }

object Cache {

  private def withLocal(artifact: Artifact, cache: Seq[(String, File)]): Artifact = {
    def local(url: String) =
      if (url.startsWith("file:///"))
        url.stripPrefix("file://")
      else if (url.startsWith("file:/"))
        url.stripPrefix("file:")
      else {
        val localPathOpt = cache.collectFirst {
          case (base, cacheDir) if url.startsWith(base) =>
            cacheDir + "/" + url.stripPrefix(base)
        }

        localPathOpt.getOrElse {
          // FIXME Means we were handed an artifact from repositories other than the known ones
          println(cache.mkString("\n"))
          println(url)
          ???
        }
      }

    if (artifact.extra.contains("local"))
      artifact
    else
      artifact.copy(extra = artifact.extra + ("local" ->
        artifact.copy(
          url = local(artifact.url),
          checksumUrls = artifact.checksumUrls
            .mapValues(local)
            .toVector
            .toMap,
          extra = Map.empty
        )
      ))
  }

  private def download(
    artifact: Artifact,
    cache: Seq[(String, File)],
    checksums: Set[String],
    cachePolicy: CachePolicy,
    pool: ExecutorService,
    logger: Option[Logger] = None
  ): Task[Seq[((File, String), FileError \/ Unit)]] = {

    implicit val pool0 = pool

{'fraction_non_alphanumeric': 0.12037037037037036, 'fraction_numerical': 0.0005787037037037037, 'mean_word_length': 2.477867203219316, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6258817', 'n_tokens_mistral': 1042, 'n_tokens_neox': 1001, 'n_words': 235}