Пример #1
0
func (node *Node) Unpin(hash multihash.Multihash) error {
	nd, err := node.proc()
	if err != nil {
		return err
	}

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

	return nil
}
Пример #2
0
		if err != nil {
			res.SetError(err, cmds.ErrNormal)
			return
		}

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

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

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

			buf := new(bytes.Buffer)