Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Commit 0ee8672

Browse files
committed
implement add without pinning
1 parent e77c2bd commit 0ee8672

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

shell.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,15 @@ type object struct {
112112

113113
// Add a file to ipfs from the given reader, returns the hash of the added file
114114
func (s *Shell) Add(r io.Reader) (string, error) {
115+
return s.addWithOpts(r, true)
116+
}
117+
118+
// AddNoPin a file to ipfs from the given reader, returns the hash of the added file without pinning the file
119+
func (s *Shell) AddNoPin(r io.Reader) (string, error) {
120+
return s.addWithOpts(r, false)
121+
}
122+
123+
func (s *Shell) addWithOpts(r io.Reader, pin bool) (string, error) {
115124
var rc io.ReadCloser
116125
if rclose, ok := r.(io.ReadCloser); ok {
117126
rc = rclose
@@ -127,6 +136,9 @@ func (s *Shell) Add(r io.Reader) (string, error) {
127136
req := NewRequest(s.url, "add")
128137
req.Body = fileReader
129138
req.Opts["progress"] = "false"
139+
if !pin {
140+
req.Opts["pin"] = "false"
141+
}
130142

131143
resp, err := req.Send(s.httpcli)
132144
if err != nil {

0 commit comments

Comments
 (0)