diff --git a/packages/pds/src/migrate-script/load-failed-blobs.ts b/packages/pds/src/migrate-script/load-failed-blobs.ts new file mode 100644 index 00000000000..654248a88f2 --- /dev/null +++ b/packages/pds/src/migrate-script/load-failed-blobs.ts @@ -0,0 +1,31 @@ +import fs from 'fs/promises' +import { chunkArray } from '@atproto/common' +import { getDb } from './db' + +const run = async () => { + const file = await fs.readFile('missing-blobs.txt') + const rows = file + .toString() + .split('\n') + .filter((row) => row.length > 5) + .map((row) => { + const [did, cid] = row.split(' ') + return { + did: did.trim(), + cid: cid.trim(), + } + }) + const db = getDb() + + await Promise.all( + chunkArray(rows, 500).map((chunk) => + db + .insertInto('failed_blob') + .values(chunk) + .onConflict((oc) => oc.doNothing()) + .execute(), + ), + ) +} + +run()