Files
reverse-engineering-anything/scripts/fixtures/android/fetch.mjs
T
morluto 53e892d43e fix(ci): retry transient release-host failures when fetching pinned fixtures (#15426)
* fix(ci): retry transient release-host failures when fetching pinned fixtures

The scheduled CI sweep on 0b7f2229b5 failed android_metadata because
GitHub's release host answered one ApiDemos APK request with HTTP 618;
the Android and Harmony fixture fetchers gave up on the first response.

Both now fetch through one helper that retries network errors, HTTP 429
and HTTP 5xx-or-above up to three attempts with a short backoff, and
fails at once on any other status. Size and SHA-256 verification are
unchanged, so a retry cannot admit different bytes.

* fix(ci): retry fixture downloads interrupted while reading the body

The retry covered only the response headers: a reset or timeout while
streaming the body surfaced from each caller's read loop and failed after
one request. downloadFixture now owns the whole download. Each attempt
streams into a fresh partial file and hash, and network errors before or
during the body are retried. A permanent HTTP status, a size or SHA-256
mismatch, and local file errors still fail at once. Both fetchers drop
their duplicated existing-file check, streaming, hashing and size checks.
2026-12-01 05:45:07 +00:00

32 lines
948 B
JavaScript

import { downloadFixture } from "../../lib/fixture-download.mjs";
import { mkdir } from "node:fs/promises";
import { resolve, join } from "node:path";
import { fileURLToPath } from "node:url";
import { JADX_RELEASE } from "../../../src/android/JadxRelease.ts";
import fixture from "./apidemos.json" with { type: "json" };
const args = process.argv.slice(2);
if (args.length > 1)
throw new Error("Usage: npm run fixtures:android -- [DIRECTORY]");
const directory = resolve(
args[0] ??
fileURLToPath(
new URL("../../../_reference/apk-integration/", import.meta.url),
),
);
await mkdir(directory, { recursive: true });
for (const item of [
{
url: JADX_RELEASE.url,
sha256: JADX_RELEASE.sha256,
filename: `jadx-headless-mcp-${JADX_RELEASE.version}-all.jar`,
},
fixture,
])
await downloadFixture({
url: item.url,
path: join(directory, item.filename),
sha256: item.sha256,
timeoutMs: 120_000,
});