<commit_before>/* sbt -- Simple Build Tool
 * Copyright 2010  <NAME>
 */
package sbt

import java.io.File

import org.apache.ivy.core.{module, report}
import module.id.ModuleRevisionId
import report.{ArtifactDownloadReport, ConfigurationResolveReport, ResolveReport}

object IvyRetrieve
{
	def reports(report: ResolveReport): Map[String, ConfigurationResolveReport] =
		( for( conf <- report.getConfigurations) yield (conf, report.getConfigurationReport(conf)) ).toMap

	def artifactReports(confReport: ConfigurationResolveReport): Seq[ArtifactDownloadReport] =
	{
		val all = new scala.collection.mutable.HashSet[ArtifactDownloadReport]
		for( revId <- confReport.getModuleRevisionIds.toArray collect { case revId: ModuleRevisionId => revId })
			all ++= confReport.getDownloadReports(revId)
		all.toSeq
	}

	def cachePath(reports: Seq[ArtifactDownloadReport]): Seq[File] =
		reports map( _.getLocalFile )

	def cachePaths(report: ResolveReport): Map[String, Seq[File]] =
		reports(report).mapValues(confReport => cachePath(artifactReports(confReport)))

	def copy(files: Set[File], cacheBase: File, to: File): Map[File, File] =
	{
		import Path._
		val copyDef = files x rebase(cacheBase, to)
		IO.copy( copyDef, overwrite = true, preserveLastModified = true )
		copyDef.toMap
	}

	// TODO: not a sufficient way to do it: cacheBase is not necessarily common to all files
	def retrieve(result: Map[String, Seq[File]], cacheBase: File, to: File): Map[String, Seq[File]] =
	{
		val all = result.values.flatten.toSet
		val copyMap = copy(all, cacheBase, to)
		result mapValues (_ map copyMap)
	}
}<commit_msg>check for non-existing local file after retrieve<commit_after>/* sbt -- Simple Build Tool
 * Copyright 2010  <NAME>
 */
package sbt

import java.io.File

import org.apache.ivy.core.{module, report}
import module.id.ModuleRevisionId
import report.{ArtifactDownloadReport, ConfigurationResolveReport, ResolveReport}

object IvyRetrieve
{
	def reports(report: ResolveReport): Map[String, ConfigurationResolveReport] =
		( for( conf <- report.getConfigurations) yield (conf, report.getConfigurationReport(conf)) ).toMap

	def artifactReports(confReport: ConfigurationResolveReport): Seq[ArtifactDownloadReport] =
	{
		val all = new scala.collection.mutable.HashSet[ArtifactDownloadReport]
		for( revId <- confReport.getModuleRevisionIds.toArray collect { case revId: ModuleRevisionId => revId })
			all ++= confReport.getDownloadReports(revId)
		all.toSeq
	}

	def cachePath(reports: Seq[ArtifactDownloadReport]): Seq[File] =
		for(r <- reports) yield
		{
			val file = r.getLocalFile
			if(file eq null) error("No file for " + r.getArtifact) else file
		}

	def cachePaths(report: ResolveReport): Map[String, Seq[File]] =
		reports(report).mapValues(confReport => cachePath(artifactReports(confReport)))
}
{'fraction_non_alphanumeric': 0.11213955144179423, 'fraction_numerical': 0.002847988608045568, 'mean_word_length': 5.474654377880184, 'pattern_counts': {'":': 0, '<': 10, '<?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': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4472959', 'n_tokens_mistral': 933, 'n_tokens_neox': 869, 'n_words': 216}