c2pa-rs

A fork of https://github.com/contentauth/c2pa-rs/
git clone git://archive.git.mtrnord.blog/mtrnords-photography-manager/c2pa-rs.git
Log | Files | Refs | README

commit 516488f91e04f3c3ee1084fc67f71941b563ffab
parent 234d05e59c065d7e183a9093fc7e09aea4e69df5
Author: Gavin  Peacock <gpeacock@adobe.com>
Date:   Mon, 24 Apr 2023 12:39:19 -0700

Fixes bug in Ingredient_from_stream_info (#241)

caused invalid ingredient loading
Diffstat:
Msdk/src/ingredient.rs | 19++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/sdk/src/ingredient.rs b/sdk/src/ingredient.rs @@ -445,15 +445,13 @@ impl Ingredient { // if we can open the file try tto get xmp info let xmp_info = XmpInfo::from_source(stream, &format); - let mut ingredient = Self { - title: title.into(), - format, - ..Default::default() + let id = if let Some(id) = xmp_info.instance_id { + id + } else { + default_instance_id() }; - if let Some(instance_id) = xmp_info.instance_id { - ingredient.instance_id = instance_id; - } + let mut ingredient = Self::new(title.into(), format, id); ingredient.document_id = xmp_info.document_id; // use document id if one exists ingredient.provenance = xmp_info.provenance; @@ -1242,6 +1240,13 @@ mod tests_file_io { assert!(ingredient.provenance().is_none()); assert!(ingredient.manifest_data().is_none()); assert!(ingredient.metadata().is_none()); + assert!(ingredient.instance_id().starts_with("xmp.iid:")); + #[cfg(feature = "add_thumbnails")] + assert!(ingredient + .thumbnail_ref() + .unwrap() + .identifier + .starts_with("xmp.iid")); } #[test]