1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-20 19:19:06 +08:00

Merge pull request #5550 from ipfs/fix/coreapi-pin-lock

take the pinlock when updating pins
This commit is contained in:
Steven Allen
2018-10-02 16:05:45 -07:00
committed by GitHub

View File

@ -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
@ -77,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