Skip to content

Commit

Permalink
not concurrent
Browse files Browse the repository at this point in the history
  • Loading branch information
dholms committed Nov 8, 2023
1 parent 867c997 commit 1a99165
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions packages/pds/src/migrate-script/repair-blobs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import dotenv from 'dotenv'
import PQueue from 'p-queue'
import AtpAgent from '@atproto/api'
import { envToCfg, envToSecrets, readEnv } from '../config'
import AppContext from '../context'
Expand Down Expand Up @@ -28,24 +27,20 @@ export const runScript = async () => {
.selectAll()
.execute()
let count = 0
const blobQueue = new PQueue({ concurrency: 1 })
for (const blob of failed) {
const pdsInfo = pdsInfos.find((info) => info.id === blob.pdsId)
if (!pdsInfo) {
throw new Error(`could not find pds with id: ${blob.pdsId}`)
}
blobQueue.add(async () => {
try {
await repairBlob(ctx, db, pdsInfo, blob.did, blob.cid, adminHeaders)
} catch (err) {
console.log(err?.['message'])
console.log(err?.['code'])
}
count++
console.log(`${count}/${failed.length}`)
})
try {
await repairBlob(ctx, db, pdsInfo, blob.did, blob.cid, adminHeaders)
} catch (err) {
console.log(err?.['message'])
console.log(err?.['code'])
}
count++
console.log(`${count}/${failed.length}`)
}
await blobQueue.onIdle()
console.log('DONE WITH ALL')
}

Expand Down

0 comments on commit 1a99165

Please sign in to comment.