c2pa-rs icon indicating copy to clipboard operation
c2pa-rs copied to clipboard

Cleanup issue: Leftover dead code in the CLI tool

Open puhley opened this issue 9 months ago • 1 comments

On line 617 of cli/src/main.rs, a ManifestDefinition is created and a claim generator is set within the ManifestDefinition.

        // read the manifest information
        let manifest_def: ManifestDef = serde_json::from_slice(json.as_bytes())?;
        let mut builder = Builder::from_json(&json)?;
        let mut manifest = manifest_def.manifest;

        // add claim_tool generator so we know this was created using this tool
        let mut tool_generator = ClaimGeneratorInfo::new(env!("CARGO_PKG_NAME"));
        tool_generator.set_version(env!("CARGO_PKG_VERSION"));
        if !manifest.claim_generator_info.is_empty()
            || manifest.claim_generator_info[0].name == "c2pa-rs"
        {
            manifest.claim_generator_info = vec![tool_generator];
        } else {
            manifest.claim_generator_info.insert(1, tool_generator);
        }

However, this manifest variable isn't used anywhere going forward. The builder object has its own ClaimGeneratorInfo property which gets set to a default when it is initialized. Therefore, setting the claim_generator_info on the orphaned manifest variable has no affect on what is finally created.

To set the claim_generator_info for the builder, you would need to call builder.set_claim_generator_info().

puhley avatar Apr 04 '25 02:04 puhley