Fix ownership reconcile on the batch import route

The Studio's batch import uses /api/admin/import/furni/batch, which never
ran the offer_id reconciliation or the www-data ownership fix (only the
single/legacy-batch route did). Run both after the batch finishes and
report the counts in the batch_complete SSE event.
This commit is contained in:
openhands committed 2026-08-18 20:01:18 +02:00
1 parent 18825115a4
commit 99e77d9872
1 file changed
+17
@@ -6,7 +6,9 @@ import { getSource } from "@/lib/services/clone-sources";
import { appendFurniEntriesBatch } from "@/lib/services/furni-data";
import {
ensureDirectories,
ensureFurniOwnership,
importSingleFurni,
reconcileImportedOfferIds,
} from "@/lib/services/furni-import";
import { rcon } from "@/lib/services/rcon";
import type { ImportSingleResult } from "@/types/furni";
@@ -211,11 +213,26 @@ export const POST = withAdmin(
}
}
// Reconcile offer_id and fix asset ownership across the whole tree
let offerIdsFixed = 0;
let ownershipFixed: string[] = [];
try {
offerIdsFixed = (await reconcileImportedOfferIds()).fixed;
ownershipFixed = (await ensureFurniOwnership()).fixed;
} catch (err) {
console.warn(
"[import-furni] Post-import reconcile/ownership failed:",
(err as Error).message,
);
}
send({
type: "batch_complete",
succeeded,
failed,
warnings: withWarnings,
offerIdsFixed,
ownershipFixed,
duration: Date.now() - startTime,
});