From d211b5eb69d97ef4743c6ec2db07eba6f6c41cf7 Mon Sep 17 00:00:00 2001 From: Phi Date: Mon, 3 Apr 2023 14:04:45 +0200 Subject: [PATCH] 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. --- cmd/lotus-miner/sectors.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/lotus-miner/sectors.go b/cmd/lotus-miner/sectors.go index 8d3a4c884..a32f276a8 100644 --- a/cmd/lotus-miner/sectors.go +++ b/cmd/lotus-miner/sectors.go @@ -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)) }, }