From 7d35a88b39b2d4beea9bf104c2e699d61625aabd Mon Sep 17 00:00:00 2001 From: cc Date: Tue, 14 Apr 2026 16:47:03 +0200 Subject: [PATCH] Fix KV engine to handle version_build URL format and array index data The keys/paths pages failed to load because: 1. findOS expected just build ID but URL contains version_build format 2. openKV expected object format but index files use array format --- src/lib/engine/kv.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/lib/engine/kv.ts b/src/lib/engine/kv.ts index 976ac10..5325641 100644 --- a/src/lib/engine/kv.ts +++ b/src/lib/engine/kv.ts @@ -61,13 +61,13 @@ export class KVEngine implements Engine { async getPaths(build: string): Promise { const os = await this.findOS(build); - const tag = `${os.version}_${build}`; + const tag = `${os.version}_${os.build}`; return fetchLines(`${this.#baseURL}/${tag}/paths.txt`); } async getBinaryXML(build: string, path: string): Promise { const os = await this.findOS(build); - const tag = `${os.version}_${build}`; + const tag = `${os.version}_${os.build}`; const reader = await this.openKV(`${this.#baseURL}/${tag}/blobs`); const blob = await reader.get(path); @@ -80,14 +80,14 @@ export class KVEngine implements Engine { async getKeys(build: string): Promise { const os = await this.findOS(build); - const tag = `${os.version}_${build}`; + const tag = `${os.version}_${os.build}`; const reader = await this.openKV(`${this.#baseURL}/${tag}/keys`); return [...reader.keys()]; } async getPathsForKey(build: string, key: string): Promise { const os = await this.findOS(build); - const tag = `${os.version}_${build}`; + const tag = `${os.version}_${os.build}`; const reader = await this.openKV(`${this.#baseURL}/${tag}/keys`); const lines = await reader.get(key); return lines.split("\n").filter(Boolean); @@ -99,7 +99,10 @@ export class KVEngine implements Engine { if (!this.#osCache) { this.#osCache = await this.listOS(); } - const os = this.#osCache.find((o) => o.build === build); + // Handle both "23E254" and "26.4.1_23E254" formats + const os = this.#osCache.find( + (o) => o.build === build || `${o.version}_${o.build}` === build + ); if (!os) throw new Error(`OS not found for build: ${build}`); return os; } @@ -107,7 +110,11 @@ export class KVEngine implements Engine { private async openKV(baseURL: string): Promise { const recordsURL = baseURL + ".index.json"; const blobsURL = baseURL + ".txt"; - const records = await fetch(recordsURL).then((r) => r.json()); + const raw = await fetch(recordsURL).then((r) => r.json()); + // Handle both array format [key, offset, length] and object format {key, offset, length} + const records: KVRecord[] = raw.map((r: [string, number, number] | KVRecord) => + Array.isArray(r) ? { key: r[0], offset: r[1], length: r[2] } : r + ); return new KVStore(records, blobsURL); } }