fix: cli: Check if the sector exists

Check if the sector exists before running `SectorRemove`, and error out if the SectorID has not bee created.
This commit is contained in:
Phi 2023-04-03 14:04:45 +02:00
parent 740a7ca142
commit d211b5eb69

View File

@ -1392,6 +1392,12 @@ var sectorsRemoveCmd = &cli.Command{
return xerrors.Errorf("could not parse sector number: %w", err)
}
// Check if the sector exists
_, err = minerAPI.SectorsStatus(ctx, abi.SectorNumber(id), false)
if err != nil {
return xerrors.Errorf("sectorID %d has not been created yet: %w", id, err)
}
return minerAPI.SectorRemove(ctx, abi.SectorNumber(id))
},
}