From 99feecfdccc3ec4801ce21633cc7ee49315f4ee9 Mon Sep 17 00:00:00 2001 From: Overbool Date: Thu, 13 Dec 2018 23:02:55 +0800 Subject: [PATCH 1/3] cmds/pin: use coreapi/pin License: MIT Signed-off-by: Overbool --- core/commands/pin.go | 113 ++++++++++++++++++-------- core/coreapi/interface/options/pin.go | 36 +++++++- core/coreapi/interface/pin.go | 2 +- core/coreapi/pin.go | 25 ++++-- core/corerepo/pinning.go | 80 ------------------ 5 files changed, 134 insertions(+), 122 deletions(-) diff --git a/core/commands/pin.go b/core/commands/pin.go index 90123464500..fc20b7df74e 100644 --- a/core/commands/pin.go +++ b/core/commands/pin.go @@ -10,9 +10,9 @@ import ( core "github.com/ipfs/go-ipfs/core" cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv" e "github.com/ipfs/go-ipfs/core/commands/e" + coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" iface "github.com/ipfs/go-ipfs/core/coreapi/interface" options "github.com/ipfs/go-ipfs/core/coreapi/interface/options" - corerepo "github.com/ipfs/go-ipfs/core/corerepo" pin "github.com/ipfs/go-ipfs/pin" cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" @@ -88,30 +88,26 @@ var addPinCmd = &cmds.Command{ return err } - enc, err := cmdenv.GetCidEncoder(req) - if err != nil { - return err - } - if !showProgress { - added, err := corerepo.Pin(n.Pinning, api, req.Context, req.Arguments, recursive) + added, err := pinAddMany(req.Context, api, req.Arguments, recursive) if err != nil { return err } - return cmds.EmitOnce(res, &AddPinOutput{Pins: cidsToStrings(added, enc)}) + + return cmds.EmitOnce(res, &AddPinOutput{Pins: added}) } v := new(dag.ProgressTracker) ctx := v.DeriveContext(req.Context) type pinResult struct { - pins []cid.Cid + pins []string err error } ch := make(chan pinResult, 1) go func() { - added, err := corerepo.Pin(n.Pinning, api, ctx, req.Arguments, recursive) + added, err := pinAddMany(req.Context, api, req.Arguments, recursive) ch <- pinResult{pins: added, err: err} }() @@ -130,7 +126,7 @@ var addPinCmd = &cmds.Command{ return err } } - return res.Emit(&AddPinOutput{Pins: cidsToStrings(val.pins, enc)}) + return res.Emit(&AddPinOutput{Pins: val.pins}) case <-ticker.C: if err := res.Emit(&AddPinOutput{Progress: v.Value()}); err != nil { return err @@ -187,6 +183,28 @@ var addPinCmd = &cmds.Command{ }, } +func pinAddMany(ctx context.Context, api coreiface.CoreAPI, paths []string, recursive bool) ([]string, error) { + added := make([]string, len(paths)) + for i, b := range paths { + p, err := coreiface.ParsePath(b) + if err != nil { + return nil, err + } + + rp, err := api.ResolvePath(ctx, p) + if err != nil { + return nil, err + } + + if err := api.Pin().Add(ctx, p, options.Pin.Recursive(recursive)); err != nil { + return nil, err + } + added[i] = rp.Cid().String() + } + + return added, nil +} + var rmPinCmd = &cmds.Command{ Helptext: cmdkit.HelpText{ Tagline: "Remove pinned objects from local storage.", @@ -204,11 +222,6 @@ collected if needed. (By default, recursively. Use -r=false for direct pins.) }, Type: PinOutput{}, Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error { - n, err := cmdenv.GetNode(env) - if err != nil { - return err - } - api, err := cmdenv.GetApi(env, req) if err != nil { return err @@ -226,20 +239,62 @@ collected if needed. (By default, recursively. Use -r=false for direct pins.) return err } - removed, err := corerepo.Unpin(n.Pinning, api, req.Context, req.Arguments, recursive) - if err != nil { - return err + for _, b := range req.Arguments { + p, err := coreiface.ParsePath(b) + if err != nil { + return err + } + + rp, err := api.ResolvePath(req.Context, p) + if err != nil { + return err + } + + if err := api.Pin().Rm(req.Context, rp, options.Pin.RmRecursive(recursive)); err != nil { + if err := res.Emit(&PinOutput{ + Pins: []string{rp.Cid().String()}, + Error: err.Error(), + }); err != nil { + return err + } + continue + } + + if err := res.Emit(&PinOutput{ + Pins: []string{rp.Cid().String()}, + }); err != nil { + return err + } } - return cmds.EmitOnce(res, &PinOutput{cidsToStrings(removed, enc)}) + return nil }, - Encoders: cmds.EncoderMap{ - cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, out *PinOutput) error { - for _, k := range out.Pins { - fmt.Fprintf(w, "unpinned %s\n", k) + PostRun: cmds.PostRunMap{ + cmds.CLI: func(res cmds.Response, re cmds.ResponseEmitter) error { + failed := false + for { + out, err := res.Next() + if err == io.EOF { + break + } else if err != nil { + return err + } + r := out.(*PinOutput) + if r.Pins == nil && r.Error != "" { + return fmt.Errorf("aborted: %s", r.Error) + } else if r.Error != "" { + failed = true + fmt.Fprintf(os.Stderr, "cannot unpin %s: %s\n", r.Pins[0], r.Error) + } else { + fmt.Fprintf(os.Stdout, "unpinned %s\n", r.Pins[0]) + } + } + + if failed { + return fmt.Errorf("some hash not unpinned") } return nil - }), + }, }, } @@ -652,11 +707,3 @@ func (r PinVerifyRes) Format(out io.Writer) { } } } - -func cidsToStrings(cs []cid.Cid, enc cidenc.Encoder) []string { - out := make([]string, 0, len(cs)) - for _, c := range cs { - out = append(out, enc.Encode(c)) - } - return out -} diff --git a/core/coreapi/interface/options/pin.go b/core/coreapi/interface/options/pin.go index 9d1107f927d..630b561de4c 100644 --- a/core/coreapi/interface/options/pin.go +++ b/core/coreapi/interface/options/pin.go @@ -8,12 +8,23 @@ type PinLsSettings struct { Type string } +// PinRmSettings represents the settings of pin rm command +type PinRmSettings struct { + Recursive bool + Force bool +} + type PinUpdateSettings struct { Unpin bool } type PinAddOption func(*PinAddSettings) error -type PinLsOption func(settings *PinLsSettings) error + +// PinRmOption pin rm option func +type PinRmOption func(*PinRmSettings) error + +// PinLsOption pin ls option func +type PinLsOption func(*PinLsSettings) error type PinUpdateOption func(*PinUpdateSettings) error func PinAddOptions(opts ...PinAddOption) (*PinAddSettings, error) { @@ -31,6 +42,21 @@ func PinAddOptions(opts ...PinAddOption) (*PinAddSettings, error) { return options, nil } +// PinRmOptions pin rm options +func PinRmOptions(opts ...PinRmOption) (*PinRmSettings, error) { + options := &PinRmSettings{ + Recursive: true, + } + + for _, opt := range opts { + if err := opt(options); err != nil { + return nil, err + } + } + + return options, nil +} + func PinLsOptions(opts ...PinLsOption) (*PinLsSettings, error) { options := &PinLsSettings{ Type: "all", @@ -102,6 +128,14 @@ func (pinOpts) Recursive(recursive bool) PinAddOption { } } +// RmRecursive is an option for Pin.Rm +func (pinOpts) RmRecursive(recursive bool) PinRmOption { + return func(settings *PinRmSettings) error { + settings.Recursive = recursive + return nil + } +} + // Type is an option for Pin.Ls which allows to specify which pin types should // be returned // diff --git a/core/coreapi/interface/pin.go b/core/coreapi/interface/pin.go index 2e119cbeae8..6e13def8f54 100644 --- a/core/coreapi/interface/pin.go +++ b/core/coreapi/interface/pin.go @@ -43,7 +43,7 @@ type PinAPI interface { Ls(context.Context, ...options.PinLsOption) ([]Pin, error) // Rm removes pin for object specified by the path - Rm(context.Context, Path) error + Rm(context.Context, Path, ...options.PinRmOption) error // Update changes one pin to another, skipping checks for matching paths in // the old tree diff --git a/core/coreapi/pin.go b/core/coreapi/pin.go index f2329c1515f..72882a20797 100644 --- a/core/coreapi/pin.go +++ b/core/coreapi/pin.go @@ -12,26 +12,27 @@ import ( cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" offline "gx/ipfs/QmYZwey1thDTynSrvd6qQkX24UpTka6TFhQ2v569UpoqxD/go-ipfs-exchange-offline" + merkledag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" ) type PinAPI CoreAPI func (api *PinAPI) Add(ctx context.Context, p coreiface.Path, opts ...caopts.PinAddOption) error { - settings, err := caopts.PinAddOptions(opts...) + dagNode, err := api.core().ResolveNode(ctx, p) if err != nil { - return err + return fmt.Errorf("pin: %s", err) } - rp, err := api.core().ResolvePath(ctx, p) + settings, err := caopts.PinAddOptions(opts...) if err != nil { return err } defer api.blockstore.PinLock().Unlock() - _, err = corerepo.Pin(api.pinning, api.core(), ctx, []string{rp.Cid().String()}, settings.Recursive) + err = api.pinning.Pin(ctx, dagNode, settings.Recursive) if err != nil { - return err + return fmt.Errorf("pin: %s", err) } return api.pinning.Flush() @@ -52,12 +53,22 @@ func (api *PinAPI) Ls(ctx context.Context, opts ...caopts.PinLsOption) ([]coreif return api.pinLsAll(settings.Type, ctx) } -func (api *PinAPI) Rm(ctx context.Context, p coreiface.Path) error { - _, err := corerepo.Unpin(api.pinning, api.core(), ctx, []string{p.String()}, true) +// Rm pin rm api +func (api *PinAPI) Rm(ctx context.Context, p coreiface.Path, opts ...caopts.PinRmOption) error { + rp, err := api.core().ResolvePath(ctx, p) if err != nil { return err } + settings, err := caopts.PinRmOptions(opts...) + if err != nil { + return err + } + + if err = api.pinning.Unpin(ctx, rp.Cid(), settings.Recursive); err != nil { + return err + } + return api.pinning.Flush() } diff --git a/core/corerepo/pinning.go b/core/corerepo/pinning.go index 9c2a02781af..e69de29bb2d 100644 --- a/core/corerepo/pinning.go +++ b/core/corerepo/pinning.go @@ -1,80 +0,0 @@ -/* -Package corerepo provides pinning and garbage collection for local -IPFS block services. - -IPFS nodes will keep local copies of any object that have either been -added or requested locally. Not all of these objects are worth -preserving forever though, so the node administrator can pin objects -they want to keep and unpin objects that they don't care about. - -Garbage collection sweeps iterate through the local block store -removing objects that aren't pinned, which frees storage space for new -objects. -*/ -package corerepo - -import ( - "context" - "fmt" - "github.com/ipfs/go-ipfs/pin" - - "github.com/ipfs/go-ipfs/core/coreapi/interface" - - "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" -) - -func Pin(pinning pin.Pinner, api iface.CoreAPI, ctx context.Context, paths []string, recursive bool) ([]cid.Cid, error) { - out := make([]cid.Cid, len(paths)) - - for i, fpath := range paths { - p, err := iface.ParsePath(fpath) - if err != nil { - return nil, err - } - - dagnode, err := api.ResolveNode(ctx, p) - if err != nil { - return nil, fmt.Errorf("pin: %s", err) - } - err = pinning.Pin(ctx, dagnode, recursive) - if err != nil { - return nil, fmt.Errorf("pin: %s", err) - } - out[i] = dagnode.Cid() - } - - err := pinning.Flush() - if err != nil { - return nil, err - } - - return out, nil -} - -func Unpin(pinning pin.Pinner, api iface.CoreAPI, ctx context.Context, paths []string, recursive bool) ([]cid.Cid, error) { - unpinned := make([]cid.Cid, len(paths)) - - for i, p := range paths { - p, err := iface.ParsePath(p) - if err != nil { - return nil, err - } - - k, err := api.ResolvePath(ctx, p) - if err != nil { - return nil, err - } - - err = pinning.Unpin(ctx, k.Cid(), recursive) - if err != nil { - return nil, err - } - unpinned[i] = k.Cid() - } - - err := pinning.Flush() - if err != nil { - return nil, err - } - return unpinned, nil -} From 7a08cf9cf3947df9089de8725b30e951287db086 Mon Sep 17 00:00:00 2001 From: Overbool Date: Sat, 15 Dec 2018 11:14:29 +0800 Subject: [PATCH 2/3] cmds/pin: modify test License: MIT Signed-off-by: Overbool --- core/commands/pin.go | 89 +++++++++------------------ core/coreapi/interface/options/pin.go | 1 - core/coreapi/pin.go | 2 - core/corerepo/pinning.go | 0 test/sharness/t0080-repo.sh | 2 +- 5 files changed, 31 insertions(+), 63 deletions(-) delete mode 100644 core/corerepo/pinning.go diff --git a/core/commands/pin.go b/core/commands/pin.go index fc20b7df74e..004b3d4e808 100644 --- a/core/commands/pin.go +++ b/core/commands/pin.go @@ -7,22 +7,22 @@ import ( "os" "time" - core "github.com/ipfs/go-ipfs/core" - cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv" - e "github.com/ipfs/go-ipfs/core/commands/e" + "github.com/ipfs/go-ipfs/core" + "github.com/ipfs/go-ipfs/core/commands/cmdenv" + "github.com/ipfs/go-ipfs/core/commands/e" + "github.com/ipfs/go-ipfs/core/coreapi/interface" coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" - iface "github.com/ipfs/go-ipfs/core/coreapi/interface" - options "github.com/ipfs/go-ipfs/core/coreapi/interface/options" - pin "github.com/ipfs/go-ipfs/pin" + "github.com/ipfs/go-ipfs/core/coreapi/interface/options" + "github.com/ipfs/go-ipfs/pin" - cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" + "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" bserv "gx/ipfs/QmVKQHuzni68SWByzJgBUCwHvvr4TWiXfutNWWwpZpp4rE/go-blockservice" - cmds "gx/ipfs/QmWGm4AbZEbnmdgVTza52MSNpEmBdFVqzmAysRbjrRyGbH/go-ipfs-cmds" + "gx/ipfs/QmWGm4AbZEbnmdgVTza52MSNpEmBdFVqzmAysRbjrRyGbH/go-ipfs-cmds" "gx/ipfs/QmYMQuypUbgsdNHmuCBSUJV6wdQVsBHRivNAp3efHJwZJD/go-verifcid" - offline "gx/ipfs/QmYZwey1thDTynSrvd6qQkX24UpTka6TFhQ2v569UpoqxD/go-ipfs-exchange-offline" + "gx/ipfs/QmYZwey1thDTynSrvd6qQkX24UpTka6TFhQ2v569UpoqxD/go-ipfs-exchange-offline" dag "gx/ipfs/Qmb2UEG2TAeVrEJSjqsZF7Y2he7wRDkrdt6c3bECxwZf4k/go-merkledag" - cidenc "gx/ipfs/QmdPQx9fvN5ExVwMhRmh7YpCQJzJrFhd1AjVBwJmRMFJeX/go-cidutil/cidenc" - cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" + "gx/ipfs/QmdPQx9fvN5ExVwMhRmh7YpCQJzJrFhd1AjVBwJmRMFJeX/go-cidutil/cidenc" + "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) var PinCmd = &cmds.Command{ @@ -68,18 +68,11 @@ var addPinCmd = &cmds.Command{ }, Type: AddPinOutput{}, Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error { - n, err := cmdenv.GetNode(env) - if err != nil { - return err - } - api, err := cmdenv.GetApi(env, req) if err != nil { return err } - defer n.Blockstore.PinLock().Unlock() - // set recursive flag recursive, _ := req.Options[pinRecursiveOptionName].(bool) showProgress, _ := req.Options[pinProgressOptionName].(bool) @@ -88,8 +81,13 @@ var addPinCmd = &cmds.Command{ return err } + enc, err := cmdenv.GetCidEncoder(req) + if err != nil { + return err + } + if !showProgress { - added, err := pinAddMany(req.Context, api, req.Arguments, recursive) + added, err := pinAddMany(req.Context, api, enc, req.Arguments, recursive) if err != nil { return err } @@ -107,7 +105,7 @@ var addPinCmd = &cmds.Command{ ch := make(chan pinResult, 1) go func() { - added, err := pinAddMany(req.Context, api, req.Arguments, recursive) + added, err := pinAddMany(ctx, api, enc, req.Arguments, recursive) ch <- pinResult{pins: added, err: err} }() @@ -183,7 +181,7 @@ var addPinCmd = &cmds.Command{ }, } -func pinAddMany(ctx context.Context, api coreiface.CoreAPI, paths []string, recursive bool) ([]string, error) { +func pinAddMany(ctx context.Context, api coreiface.CoreAPI, enc cidenc.Encoder, paths []string, recursive bool) ([]string, error) { added := make([]string, len(paths)) for i, b := range paths { p, err := coreiface.ParsePath(b) @@ -196,10 +194,10 @@ func pinAddMany(ctx context.Context, api coreiface.CoreAPI, paths []string, recu return nil, err } - if err := api.Pin().Add(ctx, p, options.Pin.Recursive(recursive)); err != nil { + if err := api.Pin().Add(ctx, rp, options.Pin.Recursive(recursive)); err != nil { return nil, err } - added[i] = rp.Cid().String() + added[i] = enc.Encode(rp.Cid()) } return added, nil @@ -239,6 +237,7 @@ collected if needed. (By default, recursively. Use -r=false for direct pins.) return err } + pins := make([]string, 0, len(req.Arguments)) for _, b := range req.Arguments { p, err := coreiface.ParsePath(b) if err != nil { @@ -250,51 +249,23 @@ collected if needed. (By default, recursively. Use -r=false for direct pins.) return err } + id := enc.Encode(rp.Cid()) + pins = append(pins, id) if err := api.Pin().Rm(req.Context, rp, options.Pin.RmRecursive(recursive)); err != nil { - if err := res.Emit(&PinOutput{ - Pins: []string{rp.Cid().String()}, - Error: err.Error(), - }); err != nil { - return err - } - continue - } - - if err := res.Emit(&PinOutput{ - Pins: []string{rp.Cid().String()}, - }); err != nil { return err } } - return nil + return cmds.EmitOnce(res, &PinOutput{pins}) }, - PostRun: cmds.PostRunMap{ - cmds.CLI: func(res cmds.Response, re cmds.ResponseEmitter) error { - failed := false - for { - out, err := res.Next() - if err == io.EOF { - break - } else if err != nil { - return err - } - r := out.(*PinOutput) - if r.Pins == nil && r.Error != "" { - return fmt.Errorf("aborted: %s", r.Error) - } else if r.Error != "" { - failed = true - fmt.Fprintf(os.Stderr, "cannot unpin %s: %s\n", r.Pins[0], r.Error) - } else { - fmt.Fprintf(os.Stdout, "unpinned %s\n", r.Pins[0]) - } + Encoders: cmds.EncoderMap{ + cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, out *PinOutput) error { + for _, k := range out.Pins { + fmt.Fprintf(w, "unpinned %s\n", k) } - if failed { - return fmt.Errorf("some hash not unpinned") - } return nil - }, + }), }, } diff --git a/core/coreapi/interface/options/pin.go b/core/coreapi/interface/options/pin.go index 630b561de4c..cc4a8ef2966 100644 --- a/core/coreapi/interface/options/pin.go +++ b/core/coreapi/interface/options/pin.go @@ -11,7 +11,6 @@ type PinLsSettings struct { // PinRmSettings represents the settings of pin rm command type PinRmSettings struct { Recursive bool - Force bool } type PinUpdateSettings struct { diff --git a/core/coreapi/pin.go b/core/coreapi/pin.go index 72882a20797..b718fb9ad49 100644 --- a/core/coreapi/pin.go +++ b/core/coreapi/pin.go @@ -6,13 +6,11 @@ import ( coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" caopts "github.com/ipfs/go-ipfs/core/coreapi/interface/options" - corerepo "github.com/ipfs/go-ipfs/core/corerepo" bserv "gx/ipfs/QmVKQHuzni68SWByzJgBUCwHvvr4TWiXfutNWWwpZpp4rE/go-blockservice" merkledag "gx/ipfs/Qmb2UEG2TAeVrEJSjqsZF7Y2he7wRDkrdt6c3bECxwZf4k/go-merkledag" cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" offline "gx/ipfs/QmYZwey1thDTynSrvd6qQkX24UpTka6TFhQ2v569UpoqxD/go-ipfs-exchange-offline" - merkledag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" ) type PinAPI CoreAPI diff --git a/core/corerepo/pinning.go b/core/corerepo/pinning.go deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/test/sharness/t0080-repo.sh b/test/sharness/t0080-repo.sh index 16e3042170a..a1ba56761ba 100755 --- a/test/sharness/t0080-repo.sh +++ b/test/sharness/t0080-repo.sh @@ -93,7 +93,7 @@ test_expect_success "pinning directly should fail now" ' ' test_expect_success "'ipfs pin rm -r=false ' should fail" ' - echo "Error: $HASH is pinned recursively" >expected4 && + echo "Error: $HASH is pinned recursively" >expected4 test_must_fail ipfs pin rm -r=false "$HASH" 2>actual4 && test_cmp expected4 actual4 ' From e2ab620f81f9fc374775159991842d8d814924e8 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 29 Jan 2019 11:27:50 -0800 Subject: [PATCH 3/3] cmds/pin: fix pin imports * Name them. Unfortunately, This makes the *actual* package names clear. I know this isn't "idiomatic go" but it's idiomatic go-ipfs. * Remove the duplicate import. License: MIT Signed-off-by: Steven Allen --- core/commands/pin.go | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/core/commands/pin.go b/core/commands/pin.go index 004b3d4e808..e59933280f1 100644 --- a/core/commands/pin.go +++ b/core/commands/pin.go @@ -7,22 +7,21 @@ import ( "os" "time" - "github.com/ipfs/go-ipfs/core" - "github.com/ipfs/go-ipfs/core/commands/cmdenv" - "github.com/ipfs/go-ipfs/core/commands/e" - "github.com/ipfs/go-ipfs/core/coreapi/interface" + core "github.com/ipfs/go-ipfs/core" + cmdenv "github.com/ipfs/go-ipfs/core/commands/cmdenv" + e "github.com/ipfs/go-ipfs/core/commands/e" coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" - "github.com/ipfs/go-ipfs/core/coreapi/interface/options" - "github.com/ipfs/go-ipfs/pin" + options "github.com/ipfs/go-ipfs/core/coreapi/interface/options" + pin "github.com/ipfs/go-ipfs/pin" - "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" + cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" bserv "gx/ipfs/QmVKQHuzni68SWByzJgBUCwHvvr4TWiXfutNWWwpZpp4rE/go-blockservice" - "gx/ipfs/QmWGm4AbZEbnmdgVTza52MSNpEmBdFVqzmAysRbjrRyGbH/go-ipfs-cmds" - "gx/ipfs/QmYMQuypUbgsdNHmuCBSUJV6wdQVsBHRivNAp3efHJwZJD/go-verifcid" - "gx/ipfs/QmYZwey1thDTynSrvd6qQkX24UpTka6TFhQ2v569UpoqxD/go-ipfs-exchange-offline" + cmds "gx/ipfs/QmWGm4AbZEbnmdgVTza52MSNpEmBdFVqzmAysRbjrRyGbH/go-ipfs-cmds" + verifcid "gx/ipfs/QmYMQuypUbgsdNHmuCBSUJV6wdQVsBHRivNAp3efHJwZJD/go-verifcid" + offline "gx/ipfs/QmYZwey1thDTynSrvd6qQkX24UpTka6TFhQ2v569UpoqxD/go-ipfs-exchange-offline" dag "gx/ipfs/Qmb2UEG2TAeVrEJSjqsZF7Y2he7wRDkrdt6c3bECxwZf4k/go-merkledag" - "gx/ipfs/QmdPQx9fvN5ExVwMhRmh7YpCQJzJrFhd1AjVBwJmRMFJeX/go-cidutil/cidenc" - "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" + cidenc "gx/ipfs/QmdPQx9fvN5ExVwMhRmh7YpCQJzJrFhd1AjVBwJmRMFJeX/go-cidutil/cidenc" + cmdkit "gx/ipfs/Qmde5VP1qUkyQXKCfmEUA7bP64V2HAptbJ7phuPp7jXWwg/go-ipfs-cmdkit" ) var PinCmd = &cmds.Command{ @@ -418,12 +417,12 @@ new pin and removing the old one. unpin, _ := req.Options[pinUnpinOptionName].(bool) - from, err := iface.ParsePath(req.Arguments[0]) + from, err := coreiface.ParsePath(req.Arguments[0]) if err != nil { return err } - to, err := iface.ParsePath(req.Arguments[1]) + to, err := coreiface.ParsePath(req.Arguments[1]) if err != nil { return err } @@ -505,7 +504,7 @@ type RefKeyList struct { Keys map[string]RefKeyObject } -func pinLsKeys(ctx context.Context, args []string, typeStr string, n *core.IpfsNode, api iface.CoreAPI) (map[cid.Cid]RefKeyObject, error) { +func pinLsKeys(ctx context.Context, args []string, typeStr string, n *core.IpfsNode, api coreiface.CoreAPI) (map[cid.Cid]RefKeyObject, error) { mode, ok := pin.StringToMode(typeStr) if !ok { @@ -515,7 +514,7 @@ func pinLsKeys(ctx context.Context, args []string, typeStr string, n *core.IpfsN keys := make(map[cid.Cid]RefKeyObject) for _, p := range args { - pth, err := iface.ParsePath(p) + pth, err := coreiface.ParsePath(p) if err != nil { return nil, err }