aboutsummaryrefslogtreecommitdiffstats
path: root/src/pack.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/pack.rs')
-rw-r--r--src/pack.rs15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/pack.rs b/src/pack.rs
index 67603d6..dda4f6a 100644
--- a/src/pack.rs
+++ b/src/pack.rs
@@ -78,8 +78,9 @@ impl SourceList {
}
/// Packs the source list at `path` into a submission in `out` (which must not exist,
-/// or be empty), checked against `schema` if one is given.
-pub fn pack(path: &Path, out: &Path, schema: Option<&Schema>) -> Result<()> {
+/// or be empty), checked against `schema` if one is given. Returns warnings: an
+/// entry whose source is text with placeholders loses its trailing line breaks.
+pub fn pack(path: &Path, out: &Path, schema: Option<&Schema>) -> Result<Vec<String>> {
let list = SourceList::load(path)?;
let dir = path
.parent()
@@ -104,10 +105,18 @@ pub fn pack(path: &Path, out: &Path, schema: Option<&Schema>) -> Result<()> {
let mut entries: BTreeMap<String, Vec<u8>> = BTreeMap::new();
let mut records: BTreeMap<String, Map<String, Value>> = BTreeMap::new();
let mut specs = Vec::new();
+ let mut warnings = Vec::new();
for (address, item) in &items {
if let Some(source) = &item.source {
let importer = importer(source, &dir, address.key.is_none())
.with_context(|| format!("item {address}"))?;
+ if address.key.is_none() && importer.is_interpolation() {
+ warnings.push(format!(
+ "item {address}: its source is text with placeholders, which loses \
+ trailing line breaks; for the entry as it is, a whole-value source \
+ (cmd:…, file:…, or a table) takes it byte-exact"
+ ));
+ }
let imported = importer
.fetch()
.with_context(|| format!("item {address}: {}", importer.describe()))?;
@@ -169,7 +178,7 @@ pub fn pack(path: &Path, out: &Path, schema: Option<&Schema>) -> Result<()> {
content::write_file(&out.join(submission::MANIFEST), &manifest_bytes, 0o600)?;
// What was written is a submission the receptor reads.
submission::Submission::load(out)?;
- Ok(())
+ Ok(warnings)
}
/// The importer `source` describes, in `dir`: raw for an entry, JSON for a record.