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