refactor(apktool): derive unavailable string counts from status (#16130)

This commit is contained in:
Vincent Koc authored and GitHub committed 2026-12-02 22:57:42 +00:00
1 parent 2ed23f31bb
commit 727331ed95
1 file changed
+8 -25
+8 -25
View File
@@ -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),