diff --git a/src/domain/artifactInspection.ts b/src/domain/artifactInspection.ts index a0b03a6e7fe..4e92a2a31bb 100644 --- a/src/domain/artifactInspection.ts +++ b/src/domain/artifactInspection.ts @@ -413,6 +413,10 @@ const uniqueOperations = ( index, ); +const rootFormatMetadata = (inventory: ArtifactInventoryResult) => + inventory.occurrences.find(({ logical_path }) => logical_path === ".") + ?.format_metadata; + const formatProbes = ( inventory: ArtifactInventoryResult, rootImage: ArtifactInspectionRootImage | undefined, @@ -479,9 +483,7 @@ const formatProbes = ( }, ]; if (format === "mcuboot") { - const rootMeta = inventory.occurrences.find( - (row) => row.logical_path === ".", - )?.format_metadata; + const rootMeta = rootFormatMetadata(inventory); const uncompressed = rootMeta?.kind === "mcuboot" && !rootMeta.compressed; return uncompressed && inventory.occurrences.some( @@ -514,9 +516,7 @@ const formatProbes = ( const bfltProbes = ( inventory: ArtifactInventoryResult, ): ArtifactInspectionResult["next_probes"] => { - const root = inventory.occurrences.find( - ({ logical_path }) => logical_path === ".", - )?.format_metadata; + const root = rootFormatMetadata(inventory); const text = inventory.occurrences.some( (row) => row.format_metadata?.kind === "bflt-segment" && @@ -557,9 +557,7 @@ const zipPackageProbes = ( const espFlashDumpProbes = ( inventory: ArtifactInventoryResult, ): ArtifactInspectionResult["next_probes"] => { - const root = inventory.occurrences.find( - ({ logical_path }) => logical_path === ".", - )?.format_metadata; + const root = rootFormatMetadata(inventory); if (root?.kind !== "esp-image") return []; const dump = root.flash_dump; if (dump === null) return [];