Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

how do i call the equivalent of ipfs add -r ? #33

Closed
jbenet opened this issue Jul 18, 2015 · 13 comments
Closed

how do i call the equivalent of ipfs add -r ? #33

jbenet opened this issue Jul 18, 2015 · 13 comments

Comments

@jbenet
Copy link
Contributor

jbenet commented Jul 18, 2015

how do i call the equivalent of ipfs add -r ?

passing the filenames is not enough as i may not be in the same machine.

is there vinyl-fs support?

@travisperson
Copy link
Contributor

vinyl-fs is supported in the sense that we support vinyl files. I haven't worked directory with the fs part reading files. But if you can get an array of vinyl files you are good to go.

See #22

@jbenet
Copy link
Contributor Author

jbenet commented Jul 18, 2015

i think add used to be able to take (string) paths. the readme example even shows this

@jbenet
Copy link
Contributor Author

jbenet commented Jul 18, 2015

fixed in #34 i believe.

@jbenet jbenet closed this as completed Jul 18, 2015
@jbenet jbenet reopened this Jul 18, 2015
@jbenet
Copy link
Contributor Author

jbenet commented Jul 18, 2015

nope, not fixed. this works for adding single files, but not directories.

the ipfs.add api should support directory named as well.

i would add vinyl-fs support, but MultipartDir cannot handle a vinyl-fs file stream.

@travisperson
Copy link
Contributor

It should handle vinyl-fs, you just can't pipe to ipfs.add. You just need to gather things prior to passing it to ipfs.add. I'm pretty sure I used that to build MultipartDir.

@haadcode
Copy link
Contributor

haadcode commented Sep 2, 2015

This is issue seemed to be fixed in 2.2.1.

You can do "ipfs add -r" with ipfs.add(directory, { recursive: true}, cb);

@ethers
Copy link
Contributor

ethers commented Sep 29, 2015

anyone have a sample Curl command for adding a directory? just a simple directory where all files are on the same local machine

@coder5876
Copy link

@haadcode Do you know if it's possible to do this in the browser, i.e. without a file system? Let's say I have some strings "hello", "world", "something", can I create an IPFS object representing a directory with files hello.txt, world.txt, something.txt containing the corresponding strings? @travisperson is this something vinyl-fs can accomplish?

@travisperson
Copy link
Contributor

I'm not sure of all the changes that have happened, but if the API hasn't changed too much since I last worked on it, you should be able to pass an array of vinyl file like objects.

ipfs.add([
{cwd: '/', base: '/', path: '/hello.txt', contents: new Buffer("Hello")},
{cwd: '/', base: '/', path: '/world.txt', contents: new Buffer("World")}
])

To wrap files in a directory you can just add a directory to the path, and building folders should work with just nesting file into directories with the path. @diasdavid can probably answer the question more directly though.

@jurgen-kluft
Copy link

The current binary on Windows does not recursively add directories, also when executing the same operation multiple times (number of files added is not consistent) ipfs can crash:

d:\Programs>ipfs add -r BC3
159.00 KB / 11.45 MB [===>---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------] 1.36 % 0←
added QmVHxkjE99HKARHmuiBhJNd8dkoBhshrGN7Z8eL7sUsukP BC3\7zxa.dll
159.37 KB / 11.45 MB [===>---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------] 1.36 % 0←
added QmYLCwWNTYPR2BXhjQ3Wdb9W28ey4QiWVSPiYQEnttmr5Z BC3\BC3Key.txt
160.31 KB / 11.45 MB [===>---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------] 1.37 % 0←
added QmTjcHKiyDP6omPtU6mvwHx4Xkzg9iSwMsYDpNSLQHSvod BC3\BCCommands.xml
160.99 KB / 11.45 MB [===>---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------] 1.37 % 0←
added QmYyAix11qNWBiy5QVwVorB3us8udSts7AFKWc8HpKWoXj BC3\BCCommands.xml.bak
164.35 KB / 11.45 MB [===>---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------] 1.40 % 0←
added QmR7iLdvHbGUoAXk69TV47GYHNxXu4EnXAeVxDtZXBiLBM BC3\BCSessions.xml
167.82 KB / 11.45 MB [===>---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------] 1.43 % 0←
added QmXVU28oPa3zL78jtK2h2dZ9XErTMjdmLs93fu6pMaHR3o BC3\BCSessions.xml.bak
296.32 KB / 11.45 MB [=====>-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------] 2.53 % 0←
added QmW8jZohtFiZSqE2rNbE1ju6XcYBGoDnZfm5iV1QUc9s5z BC3\BCShellEx.dll
676.80 KB / 11.45 MB [============>------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------] 5.77 % 0←
added QmbQzpby7cJt1oQHBSDcAydPz32HePFLYBL1YjWn5VYC3P BC3\BCShellEx64.dll
683.32 KB / 11.45 MB [============>------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------] 5.83 % 0←
added QmPjFVSKg7dK51RHqQj8dbPvfPKsnAiCxUMDJZN2tExoUg BC3\BCState.xml
689.84 KB / 11.45 MB [=============>-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------] 5.88 % 0←
added QmXsfKfFyN7whzArGFcZyMewPNnnLEWHXezowdZe6RkbJo BC3\BCState.xml.bak
780.84 KB / 11.45 MB [==============>----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------] 6.66 % 0←
added QmeNTpHYSoGBuK2Mh74URFA8fwhzhkiCRUvY4tnisTAV9V BC3\BComp.com
867.84 KB / 11.45 MB [================>--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------] 7.40 % 0←
added QmcYaQ6ezMbFRYz7wLqc9dzBHWZ6B1CUAbrY9ZkDpibWSS BC3\BComp.exe
Exception 0xe06d7363 0x19930520 0x6f9c0 0x7fefd70b3dd
PC=0x7fefd70b3dd

syscall.Syscall9(0x7fefeed13b0, 0x7, 0x224, 0xc0822368b0, 0x1, 0xc082236898, 0x0, 0xc082236868, 0x0, 0x0, ...)
/usr/local/go/src/runtime/syscall_windows.go:150 +0x5c
syscall.WSASend(0x224, 0xc0822368b0, 0x80000000001, 0xc082236898, 0x0, 0xc082236868, 0x0, 0x0, 0x0)
/usr/local/go/src/syscall/zsyscall_windows.go:1529 +0xc4
net.(_netFD).Write.func1(0xc082236868, 0x0, 0x0)
/usr/local/go/src/net/fd_windows.go:513 +0x8c
net.(_ioSrv).ExecIO(0xc08202a230, 0xc082236868, 0xe12ce8, 0x7, 0xfaf7a8, 0x1000, 0x0, 0x0)
/usr/local/go/src/net/fd_windows.go:160 +0xd5
net.(_netFD).Write(0xc082236780, 0xc08224effa, 0x7006, 0x7006, 0x0, 0x0, 0x0)
/usr/local/go/src/net/fd_windows.go:514 +0x181
net.(_conn).Write(0xc08202a268, 0xc08224effa, 0x7006, 0x7006, 0x0, 0x0, 0x0)
/usr/local/go/src/net/net.go:184 +0xeb
bufio.(_Writer).Write(0xc0822231c0, 0xc08224effa, 0x7006, 0x7006, 0xffa, 0x0, 0x0)
/usr/local/go/src/bufio/bufio.go:594 +0xd8
net/http/internal.(_chunkedWriter).Write(0xc08217df00, 0xc08224e000, 0x8000, 0x8000, 0x8000, 0x0, 0x0)
/usr/local/go/src/net/http/internal/chunked.go:169 +0x1e5
io.copyBuffer(0x1b7370, 0xc08217df00, 0x1b72f0, 0xc082242be0, 0xc08224e000, 0x8000, 0x8000, 0xf98b6, 0x0, 0x0)
/usr/local/go/src/io/io.go:383 +0x2d0
io.Copy(0x1b7370, 0xc08217df00, 0x1b72f0, 0xc082242be0, 0xc08217df00, 0x0, 0x0)
/usr/local/go/src/io/io.go:351 +0x6b
net/http.(_transferWriter).WriteBody(0xc0822444d0, 0x1b7318, 0xc08202a270, 0x0, 0x0)
/usr/local/go/src/net/http/transfer.go:218 +0x2b9
net/http.(_Request).write(0xc0820caee0, 0x1b6e50, 0xc0822231c0, 0x0, 0xc082246750, 0x0, 0x0)
/usr/local/go/src/net/http/request.go:462 +0xbc0
net/http.(_persistConn).writeLoop(0xc0820a9e40)
/usr/local/go/src/net/http/transport.go:1015 +0x283
created by net/http.(_Transport).dialConn
/usr/local/go/src/net/http/transport.go:686 +0xca4

goroutine 1 [chan receive]:
github.com/ipfs/go-ipfs/core/commands.glob.func3(0x1b5a30, 0xc0820f4300, 0x1b7000, 0xc0822449a0)
/go/src/github.com/ipfs/go-ipfs/core/commands/add.go:255 +0x4b0
main.callCommand(0x1b5c30, 0xc082222940, 0x1b5a30, 0xc0820f4300, 0x1309b80, 0x12f9e60, 0x0, 0x0, 0x0, 0x0)
/go/src/github.com/ipfs/go-ipfs/cmd/ipfs/main.go:348 +0x85e
main.(*cmdInvocation).Run(0xc0822226c0, 0x1b5c30, 0xc082222940, 0x0, 0x0, 0x0, 0x0)
/go/src/github.com/ipfs/go-ipfs/cmd/ipfs/main.go:186 +0x1ec
main.main()
/go/src/github.com/ipfs/go-ipfs/cmd/ipfs/main.go:151 +0x662

goroutine 6 [chan receive]:
github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/codahale/metrics.init.1.func2()
/go/src/github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/codahale/metrics/metrics.go:321 +0x7a
created by github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/codahale/metrics.init.1
/go/src/github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/codahale/metrics/metrics.go:328 +0x82

goroutine 7 [select]:
github.com/ipfs/go-ipfs/vendor/QmQg1J6vikuXF9oDvm4wpdeAUvvkVEKW1EYDw9HhTMnP2b/go-log.(*MirrorWriter).logRoutine(0xc082006ac0)
/go/src/github.com/ipfs/go-ipfs/vendor/QmQg1J6vikuXF9oDvm4wpdeAUvvkVEKW1EYDw9HhTMnP2b/go-log/writer.go:71 +0x343
created by github.com/ipfs/go-ipfs/vendor/QmQg1J6vikuXF9oDvm4wpdeAUvvkVEKW1EYDw9HhTMnP2b/go-log.NewMirrorWriter
/go/src/github.com/ipfs/go-ipfs/vendor/QmQg1J6vikuXF9oDvm4wpdeAUvvkVEKW1EYDw9HhTMnP2b/go-log/writer.go:38 +0xe9

goroutine 8 [syscall]:
os/signal.loop()
/usr/local/go/src/os/signal/signal_unix.go:22 +0x1f
created by os/signal.init.1
/usr/local/go/src/os/signal/signal_unix.go:28 +0x3e

goroutine 15 [chan receive]:
main.(_IntrHandler).Handle.func1(0xc082191980, 0xc08217cff0)
/go/src/github.com/ipfs/go-ipfs/cmd/ipfs/main.go:542 +0xa1
created by main.(_IntrHandler).Handle
/go/src/github.com/ipfs/go-ipfs/cmd/ipfs/main.go:547 +0x9c

goroutine 40 [IO wait]:
net.runtime_pollWait(0x1b6c58, 0x72, 0xc082257610)
/usr/local/go/src/runtime/netpoll.go:157 +0x67
net.(_pollDesc).Wait(0xc0822368f0, 0x72, 0x0, 0x0)
/usr/local/go/src/net/fd_poll_runtime.go:73 +0x41
net.(_ioSrv).ExecIO(0xc08202a228, 0xc0822367e0, 0xe12ce0, 0x7, 0xfaf7a0, 0x86, 0x0, 0x0)
/usr/local/go/src/net/fd_windows.go:182 +0x177
net.(_netFD).Read(0xc082236780, 0xc08224a000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/local/go/src/net/fd_windows.go:463 +0x17e
net.(_conn).Read(0xc08202a268, 0xc08224a000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/local/go/src/net/net.go:172 +0xeb
net/http.noteEOFReader.Read(0x1b6dd8, 0xc08202a268, 0xc0820a9e98, 0xc08224a000, 0x1000, 0x1000, 0xb67280, 0x0, 0x0)
/usr/local/go/src/net/http/transport.go:1370 +0x6e
net/http.(_noteEOFReader).Read(0xc082242b00, 0xc08224a000, 0x1000, 0x1000, 0x5, 0x0, 0x0)
:126 +0xd7
bufio.(_Reader).fill(0xc082248120)
/usr/local/go/src/bufio/bufio.go:97 +0x1f0
bufio.(_Reader).ReadSlice(0xc082248120, 0xa, 0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/go/src/bufio/bufio.go:328 +0x221
net/http/internal.readLine(0xc082248120, 0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/go/src/net/http/internal/chunked.go:110 +0x52
net/http/internal.(_chunkedReader).beginChunk(0xc082246ab0)
/usr/local/go/src/net/http/internal/chunked.go:47 +0x40
net/http/internal.(_chunkedReader).Read(0xc082246ab0, 0xc08226c001, 0x5ff, 0x5ff, 0x0, 0x0, 0x0)
/usr/local/go/src/net/http/internal/chunked.go:77 +0xbe
net/http.(_body).readLocked(0xc082223440, 0xc08226c001, 0x5ff, 0x5ff, 0x0, 0x0, 0x0)
/usr/local/go/src/net/http/transfer.go:632 +0x9f
net/http.(_body).Read(0xc082223440, 0xc08226c001, 0x5ff, 0x5ff, 0x0, 0x0, 0x0)
/usr/local/go/src/net/http/transfer.go:624 +0x117
net/http.(_bodyEOFSignal).Read(0xc082223480, 0xc08226c001, 0x5ff, 0x5ff, 0x0, 0x0, 0x0)
/usr/local/go/src/net/http/transport.go:1296 +0x271
github.com/ipfs/go-ipfs/commands/http.(_httpResponseReader).Read(0xc08202a2b0, 0xc08226c001, 0x5ff, 0x5ff, 0xfaa544, 0x0, 0x0)
/go/src/github.com/ipfs/go-ipfs/commands/http/client.go:307 +0x8b
encoding/json.(_Decoder).refill(0xc082258000, 0x0, 0x0)
/usr/local/go/src/encoding/json/stream.go:152 +0x28e
encoding/json.(_Decoder).readValue(0xc082258000, 0x1, 0x0, 0x0)
/usr/local/go/src/encoding/json/stream.go:128 +0x422
encoding/json.(_Decoder).Decode(0xc082258000, 0xb2ba40, 0xc082246ea0, 0x0, 0x0)
/usr/local/go/src/encoding/json/stream.go:57 +0x160
github.com/ipfs/go-ipfs/commands/http.decodeTypedVal(0x1b40a8, 0xd0e720, 0xc082258000, 0x0, 0x0, 0x0, 0x0)
/go/src/github.com/ipfs/go-ipfs/commands/http/client.go:291 +0x10d
github.com/ipfs/go-ipfs/commands/http.readStreamedJson(0x1b5a30, 0xc0820f4300, 0x1b70b0, 0xc08202a2b0, 0xc082248540)
/go/src/github.com/ipfs/go-ipfs/commands/http/client.go:268 +0x1f8
created by github.com/ipfs/go-ipfs/commands/http.getResponse
/go/src/github.com/ipfs/go-ipfs/commands/http/client.go:207 +0x510

goroutine 34 [select]:
net/http.(_persistConn).readLoop(0xc0820a9d90)
/usr/local/go/src/net/http/transport.go:976 +0xace
created by net/http.(_Transport).dialConn
/usr/local/go/src/net/http/transport.go:685 +0xc7f

goroutine 35 [select]:
net/http.(_persistConn).writeLoop(0xc0820a9d90)
/usr/local/go/src/net/http/transport.go:1009 +0x413
created by net/http.(_Transport).dialConn
/usr/local/go/src/net/http/transport.go:686 +0xca4

goroutine 38 [select]:
net/http.(_persistConn).readLoop(0xc0820a9e40)
/usr/local/go/src/net/http/transport.go:976 +0xace
created by net/http.(_Transport).dialConn
/usr/local/go/src/net/http/transport.go:685 +0xc7f
rax 0x5eecd46f
rbx 0x6f9c0
rcx 0x6f250
rdi 0x180069528
rsi 0x3f0c8c0
rbp 0x6f990
rsp 0x6f860
r8 0x0
r9 0x0
r10 0x180000000
r11 0x6f8a0
r12 0x3f0c8c0
r13 0x1
r14 0xc0822368b0
r15 0x224
rip 0x7fefd70b3dd
rflags 0x206
cs 0x33
fs 0x53
gs 0x2b

@travisperson
Copy link
Contributor

@jurgen-kluft you will probably want to submit this as a seperate issue over at ipfs/go-ipfs. This current issue thread is about the JavaScript lib to talk to a IPFS Node.

@jurgen-kluft
Copy link

Ok, done: #176

@dignifiedquire
Copy link
Contributor

This is resolved in the latest version.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants