perf: parallelize credential migration owner analysis

This commit is contained in:
tdurieux
2026-09-08 14:28:46 +02:00
parent 1449aecf0e
commit c7eed1a6b4
5 changed files with 161 additions and 22 deletions
+6
View File
@@ -6,7 +6,12 @@ import { migrateCredentials, verifyCredentials, enforceCredentialStorage } from
async function main() {
const args = new Set(process.argv.slice(2));
const concurrencyArgs = [...args].filter(arg => arg.startsWith("--concurrency="));
if (concurrencyArgs.length > 1) throw new Error("Specify concurrency once");
const concurrency = concurrencyArgs.length ? Number(concurrencyArgs[0].slice("--concurrency=".length)) : 10;
if (!Number.isInteger(concurrency) || concurrency < 1 || concurrency > 32) throw new Error("Concurrency must be 1..32");
for (const arg of args) {
if (concurrencyArgs.includes(arg)) continue;
if (!["--apply", "--remove-legacy", "--prefer-owner-token", "--recover-owner-tokens", "--maintenance", "--verify", "--enforce"].includes(arg)) {
throw new Error("Unknown migration option");
}
@@ -26,6 +31,7 @@ async function main() {
if (result.legacy) process.exitCode = 1;
} else {
const result = await migrateCredentials(db, cipher, {
concurrency,
apply: args.has("--apply"), removeLegacy: args.has("--remove-legacy"),
preferOwnerToken: args.has("--prefer-owner-token"),
recoverOwnerTokens: args.has("--recover-owner-tokens"),