fix: skip heavy post-import consolidation on non-final clone chunks
CI / runtime-diagnostics (push) Skipped
CI / check (push) Successful in 38s
CI / release (push) Skipped
CI / deploy (push) Successful in 1m2s

The flush after every 400-item chunk was running expensive operations
(reconcileOfferIds, rebuildCatalog, verifySpriteIds, rcon updates) which
caused the import to hang after ~800 items. Now only the final chunk
triggers the full consolidation. Also raised the per-request limit from
500 to 5000 items.
This commit is contained in:
openhands committed 2026-09-01 18:29:06 +02:00
1 parent d4fbbfa243
commit 52516a368d
2 files changed
+8 -2

No files matched your search

@@ -34,6 +34,7 @@ export const POST = withAdmin(
const body = await request.json();
const sourceId: string = body.sourceId || "";
const rawClassnames: string[] = body.classnames || [];
const isFinal = body.final === true;
if (!sourceId) return apiError("Missing sourceId", 400);
if (rawClassnames.length === 0)
@@ -65,8 +66,8 @@ export const POST = withAdmin(
}
}
if (items.length > 500)
return apiError("Too many classnames (max 500)", 400);
if (items.length > 5000)
return apiError("Too many classnames (max 5000)", 400);
// FurnitureData entries for successfully cloned items are appended once
// at the end (single read-modify-write instead of one per item), which
@@ -138,6 +139,8 @@ export const POST = withAdmin(
);
}
if (!isFinal) return;
// Post-import consolidation, mirroring the furni batch route:
// force offer_id to mirror its catalog row id, keep the
// FurnitureData in sync with the new local sprite ids, verify
@@ -444,6 +444,7 @@ export function StudioClient({
for (let i = 0; i < classnames.length; i += CHUNK) {
if (abort.signal.aborted) break;
const chunk = classnames.slice(i, i + CHUNK);
const isLast = i + CHUNK >= classnames.length;
const res = await adminFetch("/api/admin/import/clone/batch", {
method: "POST",
@@ -452,6 +453,7 @@ export function StudioClient({
sourceId: activeSource,
classnames: chunk,
concurrency: 10,
final: isLast,
}),
signal: abort.signal,
});
@@ -853,6 +855,7 @@ export function StudioClient({
sourceId: activeSource,
classnames: failed,
concurrency: 10,
final: true,
}),
signal: abort.signal,
});