Skip to content

Commit c88b4b0

Browse files
committed
"block rm": remove the option to ignore pins
License: MIT Signed-off-by: Kevin Atkinson <[email protected]>
1 parent efeb789 commit c88b4b0

File tree

2 files changed

+8
-38
lines changed

2 files changed

+8
-38
lines changed

core/commands/block.go

+7-28
Original file line numberDiff line numberDiff line change
@@ -200,15 +200,7 @@ It takes a list of base58 encoded multihashs to remove.
200200
Arguments: []cmds.Argument{
201201
cmds.StringArg("hash", true, true, "Bash58 encoded multihash of block(s) to remove."),
202202
},
203-
Options: []cmds.Option{
204-
cmds.BoolOption("ignore-pins", "Ignore pins.").Default(false),
205-
},
206203
Run: func(req cmds.Request, res cmds.Response) {
207-
ignorePins, _, err := req.Option("ignore-pins").Bool()
208-
if err != nil {
209-
res.SetError(err, cmds.ErrNormal)
210-
return
211-
}
212204
n, err := req.InvocContext().GetNode()
213205
if err != nil {
214206
res.SetError(err, cmds.ErrNormal)
@@ -225,9 +217,6 @@ It takes a list of base58 encoded multihashs to remove.
225217
go func() {
226218
defer close(outChan)
227219
pinning := n.Pinning
228-
if ignorePins {
229-
pinning = nil
230-
}
231220
err := rmBlocks(n.Blockstore, pinning, outChan, keys)
232221
if err != nil {
233222
outChan <- &RemovedBlock{Error: err.Error()}
@@ -271,25 +260,15 @@ type RemovedBlock struct {
271260
Error string `json:",omitempty"`
272261
}
273262

274-
// pins may be nil
275263
func rmBlocks(blocks bs.GCBlockstore, pins pin.Pinner, out chan<- interface{}, keys []key.Key) error {
276-
var unlocker bs.Unlocker
277-
defer func() {
278-
if unlocker != nil {
279-
unlocker.Unlock()
280-
}
281-
}()
282-
stillOkay := keys
283-
if pins != nil {
284-
// Need to make sure that some operation that is
285-
// finishing with a pin is ocurr simultaneously.
286-
unlocker = blocks.GCLock()
287-
var err error
288-
stillOkay, err = checkIfPinned(pins, keys, out)
289-
if err != nil {
290-
return fmt.Errorf("pin check failed: %s", err)
291-
}
264+
unlocker := blocks.GCLock()
265+
defer unlocker.Unlock()
266+
267+
stillOkay, err := checkIfPinned(pins, keys, out)
268+
if err != nil {
269+
return fmt.Errorf("pin check failed: %s", err)
292270
}
271+
293272
for _, k := range stillOkay {
294273
err := blocks.DeleteBlock(k)
295274
if err != nil {

test/sharness/t0050-block.sh

+1-10
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,7 @@ test_expect_success "can't remove indirectly pinned block: output looks good" '
8282
grep -q "$FILE1HASH: pinned via $DIRHASH" block_rm_err
8383
'
8484

85-
test_expect_success "multi-block 'ipfs block rm --ignore-pins' succeeds" '
86-
ipfs block rm --ignore-pins $DIRHASH >actual_rm
87-
'
88-
89-
test_expect_success "multi-block 'ipfs block rm --ignore-pins' output looks good" '
90-
echo "removed $DIRHASH" > expected_rm &&
91-
test_cmp expected_rm actual_rm
92-
'
93-
94-
test_expect_success "fix up pins" '
85+
test_expect_success "remove pin" '
9586
ipfs pin rm -r $DIRHASH
9687
'
9788

0 commit comments

Comments
 (0)