Skip to content

Commit

Permalink
load failed blobs script
Browse files Browse the repository at this point in the history
  • Loading branch information
dholms committed Nov 21, 2023
1 parent b95fb0e commit 7c50f02
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions packages/pds/src/migrate-script/load-failed-blobs.ts
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 7c50f02

Please sign in to comment.