diff --git a/core/commands/block.go b/core/commands/block.go index 2fc324c5ea5..754a6919830 100644 --- a/core/commands/block.go +++ b/core/commands/block.go @@ -200,15 +200,7 @@ It takes a list of base58 encoded multihashs to remove. Arguments: []cmds.Argument{ cmds.StringArg("hash", true, true, "Bash58 encoded multihash of block(s) to remove."), }, - Options: []cmds.Option{ - cmds.BoolOption("ignore-pins", "Ignore pins.").Default(false), - }, Run: func(req cmds.Request, res cmds.Response) { - ignorePins, _, err := req.Option("ignore-pins").Bool() - if err != nil { - res.SetError(err, cmds.ErrNormal) - return - } n, err := req.InvocContext().GetNode() if err != nil { res.SetError(err, cmds.ErrNormal) @@ -225,9 +217,6 @@ It takes a list of base58 encoded multihashs to remove. go func() { defer close(outChan) pinning := n.Pinning - if ignorePins { - pinning = nil - } err := rmBlocks(n.Blockstore, pinning, outChan, keys) if err != nil { outChan <- &RemovedBlock{Error: err.Error()} @@ -271,25 +260,15 @@ type RemovedBlock struct { Error string `json:",omitempty"` } -// pins may be nil func rmBlocks(blocks bs.GCBlockstore, pins pin.Pinner, out chan<- interface{}, keys []key.Key) error { - var unlocker bs.Unlocker - defer func() { - if unlocker != nil { - unlocker.Unlock() - } - }() - stillOkay := keys - if pins != nil { - // Need to make sure that some operation that is - // finishing with a pin is ocurr simultaneously. - unlocker = blocks.GCLock() - var err error - stillOkay, err = checkIfPinned(pins, keys, out) - if err != nil { - return fmt.Errorf("pin check failed: %s", err) - } + unlocker := blocks.GCLock() + defer unlocker.Unlock() + + stillOkay, err := checkIfPinned(pins, keys, out) + if err != nil { + return fmt.Errorf("pin check failed: %s", err) } + for _, k := range stillOkay { err := blocks.DeleteBlock(k) if err != nil { diff --git a/test/sharness/t0050-block.sh b/test/sharness/t0050-block.sh index cb1deb0ff14..9190cdd6516 100755 --- a/test/sharness/t0050-block.sh +++ b/test/sharness/t0050-block.sh @@ -82,16 +82,7 @@ test_expect_success "can't remove indirectly pinned block: output looks good" ' grep -q "$FILE1HASH: pinned via $DIRHASH" block_rm_err ' -test_expect_success "multi-block 'ipfs block rm --ignore-pins' succeeds" ' - ipfs block rm --ignore-pins $DIRHASH >actual_rm -' - -test_expect_success "multi-block 'ipfs block rm --ignore-pins' output looks good" ' - echo "removed $DIRHASH" > expected_rm && - test_cmp expected_rm actual_rm -' - -test_expect_success "fix up pins" ' +test_expect_success "remove pin" ' ipfs pin rm -r $DIRHASH '