|
|
|
@ -734,6 +734,7 @@ fn parse_manifests(
|
|
|
|
|
// .into_iter()
|
|
|
|
|
.map(|(crate_name, versions)| -> Result<(String, Vec<VersionMeta>), Error> { |
|
|
|
|
let begin = Instant::now(); |
|
|
|
|
debug!(%crate_name, "parsing manifests"); |
|
|
|
|
let mut version_metas = Vec::new(); |
|
|
|
|
for index_meta in versions { |
|
|
|
|
let version = index_meta.vers.clone(); |
|
|
|
@ -765,14 +766,22 @@ fn parse_manifests(
|
|
|
|
|
let mut readme: Option<String> = None; |
|
|
|
|
if let Some(readme_path) = manifest.package.readme.as_ref() { |
|
|
|
|
let decoder = flate2::read::GzDecoder::new(&dot_crate_bytes[..]); |
|
|
|
|
if let Some(readme_content) = extract_readme_from_tar(decoder, readme_path)? { |
|
|
|
|
if let Some(readme_content) = extract_readme_from_tar(decoder, readme_path).map_err(|err| { |
|
|
|
|
error!(%crate_name, vers = %index_meta.vers, ?err, "failed to extract readme"); |
|
|
|
|
err |
|
|
|
|
})? { |
|
|
|
|
trace!(length = readme_content.len(), "extracted readme file content from .crate targz archive"); |
|
|
|
|
readme = Some(readme_content); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
let tmp = TempDir::new()?; |
|
|
|
|
let decoder = flate2::read::GzDecoder::new(&dot_crate_bytes[..]); |
|
|
|
|
tar::Archive::new(decoder).unpack(tmp.path())?; |
|
|
|
|
tar::Archive::new(decoder).unpack(tmp.path()) |
|
|
|
|
.map_err(|err| { |
|
|
|
|
error!(%crate_name, vers = %index_meta.vers, ?err, "failed to unpack to temp dir"); |
|
|
|
|
err |
|
|
|
|
})?; |
|
|
|
|
|
|
|
|
|
trace!(tmpdir = ?tmp.path(), "unpacked .crate archive to temp dir"); |
|
|
|
|
let target_dir = tmp.path().join("target"); |
|
|
|
|
std::fs::create_dir(&target_dir)?; |
|
|
|
|