From 5e2489e1284ea790472d087fd0fa27273d95ace3 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Fri, 4 Dec 2026 22:56:51 +0800 Subject: [PATCH] refactor(artifacts): share inspection root metadata lookup (#16758) --- src/domain/artifactInspection.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) 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 [];