perf: download icon and swf concurrently during furni import
CI / check (push) Successful in 33s
CI / release (push) Skipped
CI / deploy (push) Successful in 56s

Run the independent icon and swf downloads in parallel via Promise.all
instead of sequentially. The nitro fallback still runs after the swf check
since it depends on the swf result.

Combined with batch concurrency and the single FurnitureData write, this
further cuts per-item import time (roughly halves the download phase).
This commit is contained in:
openhands committed 2026-08-22 12:44:18 +02:00
1 parent 6843af235e
commit 53db4a858b
1 file changed
+21 -21
+21 -21
View File
@@ -502,6 +502,19 @@ export function __resetCatalogIdAllocatorForTests(): void {
// ── Import Single Furni ───────────────────────────────────────────── // ── Import Single Furni ─────────────────────────────────────────────
// Try each candidate URL in order until one downloads successfully.
async function tryDownloadCandidates(
urls: string[],
dest: string,
validate: "png" | "swf",
): Promise<boolean> {
for (const url of urls) {
const dl = await downloadFile(url, dest, { validate });
if (dl.ok) return true;
}
return false;
}
export async function importSingleFurni(params: { export async function importSingleFurni(params: {
id: number; id: number;
classname: string; classname: string;
@@ -703,29 +716,16 @@ export async function importSingleFurni(params: {
`https://images.habbo.com/dcr/hof_furni/${rev}/${encodeURIComponent(safeSwfName)}.swf`, `https://images.habbo.com/dcr/hof_furni/${rev}/${encodeURIComponent(safeSwfName)}.swf`,
); );
// Download icon (try all candidate URLs) // Download icon + SWF concurrently (independent assets). Each tries its
let iconOk = false; // candidate URLs in order until one succeeds.
for (const iconUrl of iconUrls) { const [iconOkResult, swfOk] = await Promise.all([
const dl = await downloadFile(iconUrl, iconPath, { validate: "png" }); tryDownloadCandidates(iconUrls, iconPath, "png"),
if (dl.ok) { tryDownloadCandidates(swfUrls, swfPath, "swf"),
iconOk = true; ]);
break; let iconOk = iconOkResult;
}
}
// Download SWF (try all candidate URLs)
let swfOk = false;
for (const swfUrl of swfUrls) {
const dl = await downloadFile(swfUrl, swfPath, { validate: "swf" });
if (dl.ok) {
swfOk = true;
break;
}
}
// ── Nitro bundle fallback: try downloading pre-made .nitro ──────── // ── Nitro bundle fallback: try downloading pre-made .nitro ────────
// If SWF download failed, try downloading a pre-made .nitro from the // Only relevant when the SWF download failed, so it runs after SWF.
// source's nitro base URL (many retro hotels ship .nitro bundles).
let nitroDownloadOk = false; let nitroDownloadOk = false;
if ( if (
!swfOk && !swfOk &&