Skip to content

Commit a086263

Browse files
committed
fix: improve setup command and ignore metadata on repairs
- Removed the optional private key from the setup command options, using global options instead. - Enhanced the private key validation message to specify the required format (64 hex characters starting with 0x). - Updated logic in add-pieces to improve readability by introducing a variable for repair state.
1 parent 83fa4a2 commit a086263

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

packages/repair-cli/src/commands/setup.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,15 @@ function validatePostgresUrl(value: string) {
2222

2323
export const setup = Cli.create('setup', {
2424
description: 'Setup the CLI',
25-
options: globalOptions.extend({
26-
privateKey: z.string().optional().describe('Private key to use'),
27-
}),
25+
options: globalOptions,
2826
run: async (c) => {
2927
try {
3028
// Private key
3129
const pk = await p.text({
3230
message: 'Enter your private key',
3331
validate(value) {
3432
if (!value || !/^0x[a-fA-F0-9]{64}$/.test(value)) {
35-
return `Invalid private key!`
33+
return `Invalid private key! (must be 64 hex characters) starting with 0x`
3634
}
3735
},
3836
initialValue: config.get('privateKey'),

packages/repair-cli/src/pipeline/add-pieces.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,15 @@ function createAddPiecesWorker({ localDb, indexerDb, repair, client, state, log
4747
let completedOps = 0
4848
let failedOps = 0
4949
let operations: OperationSelect[] = options.operations
50+
const isRepair = repair.repairDataSetId == null
5051

5152
const group = log.group(`Batch ${options.batchNumber}/${state.totalBatches}`)
5253

5354
try {
5455
const dataset = await getTargetDataset({ localDb, repairId: repair.id, client })
5556

5657
// dedupe operations by CID on the target dataset for repairs jobs
57-
if (repair.repairDataSetId == null) {
58+
if (isRepair) {
5859
operations = await dedupeCids({ indexerDb, localDb, dataSetId: dataset.dataSetId, operations })
5960
}
6061
group.message(`Pulling ${operations.length} pieces...`)
@@ -101,7 +102,7 @@ function createAddPiecesWorker({ localDb, indexerDb, repair, client, state, log
101102
clientDataSetId: dataset.clientDataSetId,
102103
pieces: operations.map((operation) => ({
103104
pieceCid: Piece.from(operation.cid),
104-
metadata: operation.metadata,
105+
metadata: isRepair ? undefined : operation.metadata,
105106
})),
106107
})
107108

0 commit comments

Comments
 (0)