fix: ensure pin rm takes a lock
Dirk McCormick committed
Jun 12, 2019 at 14:59 UTC
4ead108a8045010adee4d982cbcb0641b99ef563
1 file changed
+4
core/coreapi/pin.go
+4
@@ -67,6 +67,10 @@ func (api *PinAPI) Rm(ctx context.Context, p path.Path, opts ...caopts.PinRmOpti
67
return err
68
}
69
70
+ // Note: after unpin the pin sets are flushed to the blockstore, so we need
71
+ // to take a lock to prevent a concurrent garbage collection
72
+ defer api.blockstore.PinLock().Unlock()
73
+
74
if err = api.pinning.Unpin(ctx, rp.Cid(), settings.Recursive); err != nil {
75
return err
76
}