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:
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 { appendFurniEntriesBatch } from "@/lib/services/furni-data";
|
||||||
import {
|
import {
|
||||||
ensureDirectories,
|
ensureDirectories,
|
||||||
|
ensureFurniOwnership,
|
||||||
importSingleFurni,
|
importSingleFurni,
|
||||||
|
reconcileImportedOfferIds,
|
||||||
} from "@/lib/services/furni-import";
|
} from "@/lib/services/furni-import";
|
||||||
import { rcon } from "@/lib/services/rcon";
|
import { rcon } from "@/lib/services/rcon";
|
||||||
import type { ImportSingleResult } from "@/types/furni";
|
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({
|
send({
|
||||||
type: "batch_complete",
|
type: "batch_complete",
|
||||||
succeeded,
|
succeeded,
|
||||||
failed,
|
failed,
|
||||||
warnings: withWarnings,
|
warnings: withWarnings,
|
||||||
|
offerIdsFixed,
|
||||||
|
ownershipFixed,
|
||||||
duration: Date.now() - startTime,
|
duration: Date.now() - startTime,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user