Skip to content

Commit

Permalink
Re-include AddNoPin and AddWithOpts for backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
adamgall committed Nov 21, 2018
1 parent 6cb5dd3 commit 8308557
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
12 changes: 12 additions & 0 deletions add.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@ func (s *Shell) Add(r io.Reader, options ...func(*RequestBuilder) *RequestBuilde
return out.Hash, rb.Body(fileReader).Exec(context.Background(), &out)
}

// AddNoPin adds a file to ipfs without pinning it
// Deprecated: Use Add() with option functions instead
func (s *Shell) AddNoPin(r io.Reader) (string, error) {
return s.Add(r, Pin(false))
}

// AddWithOpts adds a file to ipfs with some additional options
// Deprecated: Use Add() with option functions instead
func (s *Shell) AddWithOpts(r io.Reader, pin bool, rawLeaves bool) (string, error) {
return s.Add(r, Pin(pin), RawLeaves(rawLeaves))
}

func (s *Shell) AddLink(target string) (string, error) {
link := files.NewLinkFile("", "", target, nil)
slf := files.NewSliceFile("", "", []files.File{link})
Expand Down
14 changes: 14 additions & 0 deletions shell_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,20 @@ func TestAddNoPin(t *testing.T) {
is.False(ok)
}

func TestAddNoPinDeprecated(t *testing.T) {
is := is.New(t)
s := NewShell(shellUrl)

h, err := s.AddNoPin(bytes.NewBufferString(randString(32)))
is.Nil(err)

pins, err := s.Pins()
is.Nil(err)

_, ok := pins[h]
is.False(ok)
}

func TestAddDir(t *testing.T) {
is := is.New(t)
s := NewShell(shellUrl)
Expand Down

0 comments on commit 8308557

Please sign in to comment.