mirror of
https://github.com/ipfs/kubo.git
synced 2025-08-06 11:31:54 +08:00
feat(cmds/add): --to-files option automates files cp (#8927)
* feat(cmds/add): --to-files option as files cp * tests(to-files): ensure error handling is covered this adds bunch of tests that guard UX around importing multiple files into MFS, and the logic around trailing slash to indicate if the MFS destination if a directory. If the destination has a trailing slash, we ensure that the directory exists and is a dir and not a file. this allows us to support adding multipl files into MFS dir: ipfs add file1.txt file2.txt --to-files /some/mfs/dir/ * docs: to-files helptext Co-authored-by: Antonio Navarro Perez <antnavper@gmail.com> Co-authored-by: Marcin Rataj <lidel@lidel.org>
This commit is contained in:
@ -581,7 +581,7 @@ const (
|
||||
|
||||
var filesReadCmd = &cmds.Command{
|
||||
Helptext: cmds.HelpText{
|
||||
Tagline: "Read a file in a given MFS.",
|
||||
Tagline: "Read a file from MFS.",
|
||||
ShortDescription: `
|
||||
Read a specified number of bytes from a file at a given offset. By default,
|
||||
it will read the entire file similar to the Unix cat.
|
||||
@ -724,11 +724,16 @@ const (
|
||||
|
||||
var filesWriteCmd = &cmds.Command{
|
||||
Helptext: cmds.HelpText{
|
||||
Tagline: "Write to a mutable file in a given filesystem.",
|
||||
Tagline: "Append to (modify) a file in MFS.",
|
||||
ShortDescription: `
|
||||
Write data to a file in a given filesystem. This command allows you to specify
|
||||
a beginning offset to write to. The entire length of the input will be
|
||||
written.
|
||||
A low-level MFS command that allows you to append data to a file. If you want
|
||||
to add a file without modifying an existing one, use 'ipfs add --to-files'
|
||||
instead.
|
||||
`,
|
||||
LongDescription: `
|
||||
A low-level MFS command that allows you to append data at the end of a file, or
|
||||
specify a beginning offset within a file to write to. The entire length of the
|
||||
input will be written.
|
||||
|
||||
If the '--create' option is specified, the file will be created if it does not
|
||||
exist. Nonexistent intermediate directories will not be created unless the
|
||||
@ -755,6 +760,22 @@ WARNING:
|
||||
Usage of the '--flush=false' option does not guarantee data durability until
|
||||
the tree has been flushed. This can be accomplished by running 'ipfs files
|
||||
stat' on the file or any of its ancestors.
|
||||
|
||||
WARNING:
|
||||
|
||||
The CID produced by 'files write' will be different from 'ipfs add' because
|
||||
'ipfs file write' creates a trickle-dag optimized for append-only operations
|
||||
See '--trickle' in 'ipfs add --help' for more information.
|
||||
|
||||
If you want to add a file without modifying an existing one,
|
||||
use 'ipfs add' with '--to-files':
|
||||
|
||||
> ipfs files mkdir -p /myfs/dir
|
||||
> ipfs add example.jpg --to-files /myfs/dir/
|
||||
> ipfs files ls /myfs/dir/
|
||||
example.jpg
|
||||
|
||||
See '--to-files' in 'ipfs add --help' for more information.
|
||||
`,
|
||||
},
|
||||
Arguments: []cmds.Argument{
|
||||
@ -1019,7 +1040,7 @@ func updatePath(rt *mfs.Root, pth string, builder cid.Builder) error {
|
||||
|
||||
var filesRmCmd = &cmds.Command{
|
||||
Helptext: cmds.HelpText{
|
||||
Tagline: "Remove a file.",
|
||||
Tagline: "Remove a file from MFS.",
|
||||
ShortDescription: `
|
||||
Remove files or directories.
|
||||
|
||||
|
Reference in New Issue
Block a user