Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
02dc2604
Commit
02dc2604
authored
Jul 29, 2017
by
Jeromy Johnson
Committed by
GitHub
Jul 29, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4082 from te0d/feat/commands/add-size
ipfs add: added size to response of `ipfs add` command
parents
9825e339
f96f6af9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
0 deletions
+30
-0
core/coreunix/add.go
core/coreunix/add.go
+9
-0
test/sharness/t0410-api-add.sh
test/sharness/t0410-api-add.sh
+21
-0
No files found.
core/coreunix/add.go
View file @
02dc2604
...
...
@@ -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"
...
...
@@ -46,6 +47,7 @@ type Link struct {
type
Object
struct
{
Hash
string
Links
[]
Link
Size
string
}
type
hiddenFileError
struct
{
...
...
@@ -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
)
{
...
...
@@ -548,6 +551,7 @@ func outputDagnode(out chan interface{}, name string, dn node.Node) error {
out
<-
&
AddedObject
{
Hash
:
o
.
Hash
,
Name
:
name
,
Size
:
o
.
Size
,
}
return
nil
...
...
@@ -563,9 +567,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
())),
}
...
...
test/sharness/t0410-api-add.sh
0 → 100755
View file @
02dc2604
#!/bin/sh
#
# Copyright (c) 2016 Tom O'Donnell
# MIT Licensed; see the LICENSE file in this repository.
#
test_description
=
"Test API add command"
.
lib/test-lib.sh
test_init_ipfs
# Verify that that API add command returns size
test_launch_ipfs_daemon
test_expect_success
"API Add response includes size field"
'
echo "hi" | curl -s -F file=@- "http://localhost:$API_PORT/api/v0/add" | grep "\"Size\": *\"11\""
'
test_kill_ipfs_daemon
test_done
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment