mirror of
https://github.com/ipfs/kubo.git
synced 2025-08-06 11:31:54 +08:00
defer the pinlock till we actually need it
License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
This commit is contained in:
@ -22,13 +22,13 @@ func (api *PinAPI) Add(ctx context.Context, p coreiface.Path, opts ...caopts.Pin
|
||||
return err
|
||||
}
|
||||
|
||||
defer api.node.Blockstore.PinLock().Unlock()
|
||||
|
||||
rp, err := api.core().ResolvePath(ctx, p)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer api.node.Blockstore.PinLock().Unlock()
|
||||
|
||||
_, err = corerepo.Pin(api.node, api.core(), ctx, []string{rp.Cid().String()}, settings.Recursive)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -67,8 +67,6 @@ func (api *PinAPI) Update(ctx context.Context, from coreiface.Path, to coreiface
|
||||
return err
|
||||
}
|
||||
|
||||
defer api.node.Blockstore.PinLock().Unlock()
|
||||
|
||||
fp, err := api.core().ResolvePath(ctx, from)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -79,6 +77,8 @@ func (api *PinAPI) Update(ctx context.Context, from coreiface.Path, to coreiface
|
||||
return err
|
||||
}
|
||||
|
||||
defer api.node.Blockstore.PinLock().Unlock()
|
||||
|
||||
err = api.node.Pinning.Update(ctx, fp.Cid(), tp.Cid(), settings.Unpin)
|
||||
if err != nil {
|
||||
return err
|
||||
|
Reference in New Issue
Block a user