Skip to content

Commit

Permalink
ipfs add: added size to response of ipfs add command
Browse files Browse the repository at this point in the history
The `ipfs add` command was modified to include the added
node's size as a string. The size is included in the
dagnode info sent over the output channel.

License: MIT
Signed-off-by: Tom O'Donnell [email protected]
  • Loading branch information
te0d committed Jul 19, 2017
1 parent 4c34870 commit 923797e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions core/coreunix/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io/ioutil"
"os"
gopath "path"
"strconv"

bs "github.com/ipfs/go-ipfs/blocks/blockstore"
bstore "github.com/ipfs/go-ipfs/blocks/blockstore"
Expand Down Expand Up @@ -46,6 +47,7 @@ type Link struct {
type Object struct {
Hash string
Links []Link
Size string
}

type hiddenFileError struct {
Expand All @@ -68,6 +70,7 @@ type AddedObject struct {
Name string
Hash string `json:",omitempty"`
Bytes int64 `json:",omitempty"`
Size string `json:",omitempty"`
}

func NewAdder(ctx context.Context, p pin.Pinner, bs bstore.GCBlockstore, ds dag.DAGService) (*Adder, error) {
Expand Down Expand Up @@ -543,6 +546,7 @@ func outputDagnode(out chan interface{}, name string, dn node.Node) error {
out <- &AddedObject{
Hash: o.Hash,
Name: name,
Size: o.Size,
}

return nil
Expand All @@ -558,9 +562,14 @@ func NewMemoryDagService() dag.DAGService {
// from core/commands/object.go
func getOutput(dagnode node.Node) (*Object, error) {
c := dagnode.Cid()
s, err := dagnode.Size()
if err != nil {
return nil, err
}

output := &Object{
Hash: c.String(),
Size: strconv.FormatUint(s, 10),
Links: make([]Link, len(dagnode.Links())),
}

Expand Down

1 comment on commit 923797e

@GitCop
Copy link

@GitCop GitCop commented on 923797e Jul 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were the following issues with your Pull Request

We ask for a few features in the commit message for Open Source licensing hygiene and commit message clarity.
git commit --amend can often help you quickly improve the commit message.
Guidelines and a script are available to help in the long run.
Your feedback on GitCop is welcome on this issue.


This message was auto-generated by https://gitcop.com

Please sign in to comment.