@@ -200,15 +200,7 @@ It takes a list of base58 encoded multihashs to remove.
200
200
Arguments : []cmds.Argument {
201
201
cmds .StringArg ("hash" , true , true , "Bash58 encoded multihash of block(s) to remove." ),
202
202
},
203
- Options : []cmds.Option {
204
- cmds .BoolOption ("ignore-pins" , "Ignore pins." ).Default (false ),
205
- },
206
203
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
- }
212
204
n , err := req .InvocContext ().GetNode ()
213
205
if err != nil {
214
206
res .SetError (err , cmds .ErrNormal )
@@ -225,9 +217,6 @@ It takes a list of base58 encoded multihashs to remove.
225
217
go func () {
226
218
defer close (outChan )
227
219
pinning := n .Pinning
228
- if ignorePins {
229
- pinning = nil
230
- }
231
220
err := rmBlocks (n .Blockstore , pinning , outChan , keys )
232
221
if err != nil {
233
222
outChan <- & RemovedBlock {Error : err .Error ()}
@@ -271,25 +260,15 @@ type RemovedBlock struct {
271
260
Error string `json:",omitempty"`
272
261
}
273
262
274
- // pins may be nil
275
263
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 )
292
270
}
271
+
293
272
for _ , k := range stillOkay {
294
273
err := blocks .DeleteBlock (k )
295
274
if err != nil {
0 commit comments