@cryptotaxi247 / kubo / commits / bf654ea4f

defer the pinlock till we actually need it

License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>

Steven Allen committed Oct 2, 2018 at 15:39 UTC bf654ea4f879c7bc75c52a6fcacda24fe1214dc9
1 file changed +4 -4
core/coreapi/pin.go
+4 -4
@@ -22,13 +22,13 @@ func (api *PinAPI) Add(ctx context.Context, p coreiface.Path, opts ...caopts.Pin
22 return err
23 }
24
25 - defer api.node.Blockstore.PinLock().Unlock()
26 -
25 rp, err := api.core().ResolvePath(ctx, p)
26 if err != nil {
27 return err
28 }
29
30 + defer api.node.Blockstore.PinLock().Unlock()
31 +
32 _, err = corerepo.Pin(api.node, api.core(), ctx, []string{rp.Cid().String()}, settings.Recursive)
33 if err != nil {
34 return err
@@ -67,8 +67,6 @@ func (api *PinAPI) Update(ctx context.Context, from coreiface.Path, to coreiface
67 return err
68 }
69
70 - defer api.node.Blockstore.PinLock().Unlock()
71 -
70 fp, err := api.core().ResolvePath(ctx, from)
71 if err != nil {
72 return err
@@ -79,6 +77,8 @@ func (api *PinAPI) Update(ctx context.Context, from coreiface.Path, to coreiface
77 return err
78 }
79
80 + defer api.node.Blockstore.PinLock().Unlock()
81 +
82 err = api.node.Pinning.Update(ctx, fp.Cid(), tp.Cid(), settings.Unpin)
83 if err != nil {
84 return err