Skip to content

Commit

Permalink
better err handling
Browse files Browse the repository at this point in the history
  • Loading branch information
dholms committed Nov 4, 2023
1 parent de61594 commit 4a85750
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions packages/pds/src/migrate-script/repair-blobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ export const runScript = async () => {
if (!pdsInfo) {
throw new Error(`could not find pds with id: ${blob.pdsId}`)
}
await repairBlob(ctx, db, pdsInfo, blob.did, blob.cid, adminToken)
try {
await repairBlob(ctx, db, pdsInfo, blob.did, blob.cid, adminToken)
} catch (err) {
console.log(err)
}
count++
console.log(`${count}/${failed.length}`)
}
Expand All @@ -66,24 +70,20 @@ const repairBlob = async (
.executeTakeFirst()
if (!blob) return
const blobStream = await ctx.blobstore.getStream(CID.parse(blob.cid))
try {
await axios.post(`${pds.url}/xrpc/com.atproto.temp.pushBlob`, blobStream, {
params: { did },
headers: {
'content-type': blob.mimeType,
authorization: `Basic ${adminToken}`,
},
decompress: true,
responseType: 'stream',
})
await db
.deleteFrom('failed_blob')
.where('did', '=', did)
.where('cid', '=', blob.cid)
.execute()
} catch (err) {
console.log('failed: ', err)
}
await axios.post(`${pds.url}/xrpc/com.atproto.temp.pushBlob`, blobStream, {
params: { did },
headers: {
'content-type': blob.mimeType,
authorization: `Basic ${adminToken}`,
},
decompress: true,
responseType: 'stream',
})
await db
.deleteFrom('failed_blob')
.where('did', '=', did)
.where('cid', '=', blob.cid)
.execute()
}

runScript()

0 comments on commit 4a85750

Please sign in to comment.