From 0ee867280b9b85f2fcd6a3aa324728fc775dae48 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Thu, 6 Oct 2016 21:06:17 -0700 Subject: [PATCH] implement add without pinning --- shell.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/shell.go b/shell.go index acc62a569..291dd393f 100644 --- a/shell.go +++ b/shell.go @@ -112,6 +112,15 @@ type object struct { // Add a file to ipfs from the given reader, returns the hash of the added file func (s *Shell) Add(r io.Reader) (string, error) { + return s.addWithOpts(r, true) +} + +// AddNoPin a file to ipfs from the given reader, returns the hash of the added file without pinning the file +func (s *Shell) AddNoPin(r io.Reader) (string, error) { + return s.addWithOpts(r, false) +} + +func (s *Shell) addWithOpts(r io.Reader, pin bool) (string, error) { var rc io.ReadCloser if rclose, ok := r.(io.ReadCloser); ok { rc = rclose @@ -127,6 +136,9 @@ func (s *Shell) Add(r io.Reader) (string, error) { req := NewRequest(s.url, "add") req.Body = fileReader req.Opts["progress"] = "false" + if !pin { + req.Opts["pin"] = "false" + } resp, err := req.Send(s.httpcli) if err != nil {