From 727331ed9571f8afe640658d376cf9e224bf4c12 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Thu, 3 Dec 2026 06:57:42 +0800 Subject: [PATCH] refactor(apktool): derive unavailable string counts from status (#16130) --- src/apktool/ApktoolStringTables.ts | 33 ++++++++---------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/src/apktool/ApktoolStringTables.ts b/src/apktool/ApktoolStringTables.ts index dd153e319df..9472de36d3f 100644 --- a/src/apktool/ApktoolStringTables.ts +++ b/src/apktool/ApktoolStringTables.ts @@ -37,23 +37,9 @@ type PresentTable = { readonly unparsedCount: number; }; type UnavailableTable = - | { - readonly status: "missing"; - readonly totalCount: 0; - readonly unparsedCount: 0; - } - | { - readonly status: "oversized"; - readonly totalCount: null; - readonly unparsedCount: null; - readonly byteBudget: number; - } - | { - readonly status: "malformed"; - readonly totalCount: null; - readonly unparsedCount: null; - readonly message: string; - }; + | { readonly status: "missing" } + | { readonly status: "oversized"; readonly byteBudget: number } + | { readonly status: "malformed"; readonly message: string }; type PhysicalTable = PresentTable | UnavailableTable; /** One physical read owns parsed counts independently of output allocation. */ @@ -69,15 +55,13 @@ const readTable = async ( if (source.text === null) return { bytes: 0, - fact: { status: "missing", totalCount: 0, unparsedCount: 0 }, + fact: { status: "missing" }, }; if (source.truncated) return { bytes: source.sourceBytes, fact: { status: "oversized", - totalCount: null, - unparsedCount: null, byteBudget: budget, }, }; @@ -88,8 +72,6 @@ const readTable = async ( bytes, fact: { status: "malformed", - totalCount: null, - unparsedCount: null, message: parsed.error.message, }, }; @@ -254,13 +236,14 @@ export const projectApktoolStringTables = async ( physical.set(directory, fact); } if (fact.status !== "present") { + const missing = fact.status === "missing"; tables.push({ locale, status: fact.status, strings: [], - total_count: fact.totalCount, - unparsed_count: fact.unparsedCount, - coverage: fact.status === "missing" ? "complete" : "partial", + total_count: missing ? 0 : null, + unparsed_count: missing ? 0 : null, + coverage: missing ? "complete" : "partial", }); limitations.add( unavailableTableLimitation(fact, directory, locale, input),