Exemple #1
0
func (node *Node) Pin(hash multihash.Multihash) error {
	nd, err := node.proc()
	if err != nil {
		return err
	}

	defer nd.Blockstore.PinLock().Unlock()

	paths := []string{path.FromKey(key.Key(hash)).String()}
	if _, err := corerepo.Pin(nd, node.Context, paths, true); err != nil {
		return err
	}

	return nil
}
Exemple #2
0
		}

		unlock := n.Blockstore.PinLock()
		defer unlock()

		// set recursive flag
		recursive, found, err := req.Option("recursive").Bool()
		if err != nil {
			res.SetError(err, cmds.ErrNormal)
			return
		}
		if !found {
			recursive = true
		}

		added, err := corerepo.Pin(n, req.Context(), req.Arguments(), recursive)
		if err != nil {
			res.SetError(err, cmds.ErrNormal)
			return
		}

		res.SetOutput(&PinOutput{added})
	},
	Marshalers: cmds.MarshalerMap{
		cmds.Text: func(res cmds.Response) (io.Reader, error) {
			added, ok := res.Output().(*PinOutput)
			if !ok {
				return nil, u.ErrCast()
			}

			var pintype string