coreunix: fix Add() docs regarding pinning
License: MIT Signed-off-by: Lars Gierth <larsg@systemli.org>
Lars Gierth committed
Dec 16, 2016 at 15:13 UTC
71a03fe35d633e81b3cb39b70c5d337ad3ee92fa
1 file changed
+7
-5
core/coreunix/add.go
+7
-5
@@ -89,7 +89,7 @@ func NewAdder(ctx context.Context, p pin.Pinner, bs bstore.GCBlockstore, ds dag.
89
90
}
91
92
-// Internal structure for holding the switches passed to the `add` call
92
+// Adder holds the switches passed to the `add` command.
93
type Adder struct {
94
ctx context.Context
95
pinning pin.Pinner
@@ -114,7 +114,7 @@ func (adder *Adder) SetMfsRoot(r *mfs.Root) {
114
adder.mr = r
115
}
116
117
-// Perform the actual add & pin locally, outputting results to reader
117
+// Constructs a node from reader's data, and adds it. Doesn't pin.
118
func (adder Adder) add(reader io.Reader) (node.Node, error) {
119
chnk, err := chunk.FromString(reader, adder.Chunker)
120
if err != nil {
@@ -251,12 +251,14 @@ func (adder *Adder) outputDirs(path string, fsn mfs.FSNode) error {
251
}
252
}
253
254
-// Add builds a merkledag from the a reader, pinning all objects to the local
255
-// datastore. Returns a key representing the root node.
254
+// Add builds a merkledag node from a reader, adds it to the blockstore,
255
+// and returns the key representing that node.
256
+// If you want to pin it, use NewAdder() and Adder.PinRoot().
257
func Add(n *core.IpfsNode, r io.Reader) (string, error) {
258
return AddWithContext(n.Context(), n, r)
259
}
260
261
+// AddWithContext does the same as Add, but with a custom context.
262
func AddWithContext(ctx context.Context, n *core.IpfsNode, r io.Reader) (string, error) {
263
defer n.Blockstore.PinLock().Unlock()
264
@@ -357,7 +359,7 @@ func (adder *Adder) addNode(node node.Node, path string) error {
359
return nil
360
}
361
360
-// Add the given file while respecting the adder.
362
+// AddFile adds the given file while respecting the adder.
363
func (adder *Adder) AddFile(file files.File) error {
364
if adder.Pin {
365
adder.unlocker = adder.blockstore.PinLock()