summaryrefslogtreecommitdiff
path: root/cli/tools/registry/tar.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tools/registry/tar.rs')
-rw-r--r--cli/tools/registry/tar.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/cli/tools/registry/tar.rs b/cli/tools/registry/tar.rs
index 61532917a..418a5b0fd 100644
--- a/cli/tools/registry/tar.rs
+++ b/cli/tools/registry/tar.rs
@@ -16,11 +16,12 @@ pub fn create_gzipped_tarball(
// TODO(bartlomieju): this is too specific, factor it out into a callback that
// returns data
unfurler: ImportMapUnfurler,
-) -> Result<Bytes, AnyError> {
+) -> Result<(Bytes, Vec<String>), AnyError> {
let mut tar = TarGzArchive::new();
let dir = dir
.canonicalize()
.map_err(|_| anyhow::anyhow!("Unable to canonicalize path {:?}", dir))?;
+ let mut diagnostics = vec![];
for entry in walkdir::WalkDir::new(&dir).follow_links(false) {
let entry = entry?;
@@ -37,9 +38,11 @@ pub fn create_gzipped_tarball(
})?;
let data = std::fs::read(entry.path())
.with_context(|| format!("Unable to read file {:?}", entry.path()))?;
- let content = unfurler
+ let (content, unfurl_diagnostics) = unfurler
.unfurl(&url, data)
.with_context(|| format!("Unable to unfurl file {:?}", entry.path()))?;
+
+ diagnostics.extend_from_slice(&unfurl_diagnostics);
tar
.add_file(relative_path.to_string(), &content)
.with_context(|| {
@@ -48,12 +51,13 @@ pub fn create_gzipped_tarball(
} else if entry.file_type().is_dir() {
// skip
} else {
- log::warn!("Unsupported file type at path {:?}", entry.path());
+ diagnostics
+ .push(format!("Unsupported file type at path {:?}", entry.path()));
}
}
let v = tar.finish().context("Unable to finish tarball")?;
- Ok(Bytes::from(v))
+ Ok((Bytes::from(v), diagnostics))
}
struct TarGzArchive {