kubo icon indicating copy to clipboard operation
kubo copied to clipboard

feat(cmds/add): --to-files option as files cp

Open schomatis opened this issue 2 years ago • 7 comments

Closes https://github.com/ipfs/go-ipfs/issues/8504.

Sharness missing: https://github.com/ipfs/go-ipfs/issues/8504#issuecomment-1115031052

Example:

ipfs add p2p -r --to-files /

# added QmWSpN5PR7rkcnHQAWU8AvrAnqUtZnDfSzfFd9r5xnh7DJ p2p/listener.go
# added QmSj2YofPhB4i6LQwfBhdZZv5h7p1NNK8sTWYxT7xsKyUx p2p/local.go
# added QmaUuTcmN4y8G2E8i14U7VstZyrF6RrydbUanYkXt2hPXg p2p/p2p.go
# added QmTDkjKwN6ZxndDUnyLjdDF1yBxjr2TzBmmq2sDSgP82TE p2p/remote.go
# added QmQHnDfEdHDQPCksGNiY9asadBYMkmcQ5xKULog8FZLVJ3 p2p/stream.go
# added QmWw69M8XVQEV4tUQVYeUK9Er1v7M32X6Lz41Zg6ttzdnE p2p
 
ipfs files ls /p2p

# listener.go
# local.go
# p2p.go
# remote.go
# stream.go

schomatis avatar May 02 '22 16:05 schomatis

I can't reproduce your error. Let's just wait on @lidel's review on this one.

schomatis avatar May 04 '22 23:05 schomatis

I'm now hitting @Jorropo's error Error: expected a file argument. Not sure if this is related to the rebase, but in any case I'll delve deeper into the add command.

schomatis avatar Jul 22 '22 15:07 schomatis

This fails when running it through the daemon, fixing.

schomatis avatar Jul 25 '22 18:07 schomatis

It seems the iterator for multipartDirectory somehow consumes the state of the directory from where it's derived and we can't call it twice:

https://github.com/ipfs/go-ipfs-files/blob/88b4692b4642719bb8459a966f4b9a3da57c6e2d/multipartfile.go#L218-L221

(I could try to repackage what was iterated but seems the cleaner approach is to fix this upstream.)

schomatis avatar Jul 25 '22 18:07 schomatis

Blocked on https://github.com/ipfs/go-ipfs-files/issues/53.

schomatis avatar Jul 26 '22 15:07 schomatis

We can't easily fix https://github.com/ipfs/go-ipfs-files/issues/53 so working around it here.

schomatis avatar Aug 02 '22 16:08 schomatis

@lidel Unified loops to use the iterator only once.

schomatis avatar Aug 04 '22 17:08 schomatis

@Jorropo I tested the exact same command as you did and it is working fine. Can you have another look, please? @lidel I see that there are some sharness tests. Do we need more of them?

ajnavarro avatar Sep 09 '22 10:09 ajnavarro

2022-09-20 conversation: @lidel will check to see if more sharness tests are needed. If there are more tests needed, @lidel will specify them and @ajnavarro will do them. If there is sufficient coverage @lidel will merge.

BigLep avatar Sep 20 '22 16:09 BigLep