Skip to content

Commit

Permalink
tweak logging
Browse files Browse the repository at this point in the history
  • Loading branch information
dholms committed Nov 3, 2023
1 parent 008be35 commit 093f86f
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions packages/pds/src/migrate-script/migrate-all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ export const runScript = async () => {
.selectAll()
.execute()
let pdsCounter = 0
let completed = 0
let failed = 0
for (const status of todo) {
let pdsId = status.pdsId
if (!pdsId) {
Expand All @@ -57,14 +59,17 @@ export const runScript = async () => {
}
try {
await migrateRepo(ctx, db, pdsInfo, status, adminToken)
console.log(`completed migrating: ${status.did}`)
completed++
} catch (err) {
await db
.updateTable('status')
.set({ failed: 1 })
.where('did', '=', status.did)
.execute()
console.error(`failed to migrate: ${status.did}`, err)
failed++
}
if (completed % 5 === 0) {
console.log(`completed: ${completed}, failed: ${failed}`)
}
}
console.log('DONE WITH ALL')
Expand Down Expand Up @@ -167,17 +172,16 @@ const doImport = async (
},
)

let logOutput = ''
for await (const log of importRes.data) {
if (typeof log === 'string') {
const lines = log.split('\n')
for (const line of lines) {
if (line.includes('failed to import blob')) {
const cid = line.split(':')[1].trim()
await logFailedBlob(db, did, cid)
}
}
logOutput += log
}
const lines = logOutput.split('\n')
for (const line of lines) {
if (line.includes('failed to import blob')) {
const cid = line.split(':')[1].trim()
await logFailedBlob(db, did, cid)
}
console.log(`import update for ${did}: `, log.toString())
}
return root.rev
}
Expand Down

0 comments on commit 093f86f

Please sign in to comment.