Skip to content

Commit 85c6088

Browse files
committed
Revert da4a4ac and add more longDesc
This reverts most of the changes in da4a4ac, which were later found to be errorful. See #2657 for details. License: MIT Signed-off-by: Richard Littauer <[email protected]>
1 parent 6fdfaaf commit 85c6088

File tree

1 file changed

+25
-21
lines changed

1 file changed

+25
-21
lines changed

core/commands/add.go

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,17 @@ const (
3636

3737
var AddCmd = &cmds.Command{
3838
Helptext: cmds.HelpText{
39-
Tagline: "Add a file to ipfs.",
39+
Tagline: "Add a file or directory to ipfs.",
4040
ShortDescription: `
41-
Adds contents of <path> to ipfs. Use -r to add directories.
42-
Note that directories are added recursively, to form the ipfs
43-
MerkleDAG.
41+
Adds contents of <path> to ipfs. Use -r to add directories, recursively.
4442
`,
4543
LongDescription: `
46-
Adds contents of <path> to ipfs. Use -r to add directories.
47-
Note that directories are added recursively, to form the ipfs
48-
MerkleDAG.
44+
Adds contents of <path> to ipfs. Use -r to add directories, recursively.
45+
46+
Files and directories will be chunked and imported into ipfs. File chunks
47+
and directory entries will be linked with cryptographic hashes, forming
48+
an ipfs merkledag. For more information about how file importing works
49+
and the merkledag data structures, see <link>.
4950
5051
The wrap option, '-w', wraps the file (or files, if using the
5152
recursive option) in a directory. This directory contains only
@@ -69,13 +70,13 @@ You can now refer to the added file in a gateway, like so:
6970
},
7071
Options: []cmds.Option{
7172
cmds.OptionRecursivePath, // a builtin option that allows recursive paths (-r, --recursive)
72-
cmds.BoolOption(quietOptionName, "q", "Write minimal output.").Default(false),
73-
cmds.BoolOption(silentOptionName, "Write no output.").Default(false),
73+
cmds.BoolOption(quietOptionName, "q", "Write minimal output."),
74+
cmds.BoolOption(silentOptionName, "Write no output."),
7475
cmds.BoolOption(progressOptionName, "p", "Stream progress data."),
75-
cmds.BoolOption(trickleOptionName, "t", "Use trickle-dag format for dag generation.").Default(false),
76-
cmds.BoolOption(onlyHashOptionName, "n", "Only chunk and hash - do not write to disk.").Default(false),
77-
cmds.BoolOption(wrapOptionName, "w", "Wrap files with a directory object.").Default(false),
78-
cmds.BoolOption(hiddenOptionName, "H", "Include files that are hidden. Only takes effect on recursive add.").Default(false),
76+
cmds.BoolOption(trickleOptionName, "t", "Use trickle-dag format for dag generation."),
77+
cmds.BoolOption(onlyHashOptionName, "n", "Only chunk and hash - do not write to disk."),
78+
cmds.BoolOption(wrapOptionName, "w", "Wrap files with a directory object."),
79+
cmds.BoolOption(hiddenOptionName, "H", "Include files that are hidden. Only takes effect on recursive add."),
7980
cmds.StringOption(chunkerOptionName, "s", "Chunking algorithm to use."),
8081
cmds.BoolOption(pinOptionName, "Pin this object when adding.").Default(true),
8182
},
@@ -242,7 +243,7 @@ You can now refer to the added file in a gateway, like so:
242243
return
243244
}
244245

245-
progress, _, err := req.Option(progressOptionName).Bool()
246+
progress, prgFound, err := req.Option(progressOptionName).Bool()
246247
if err != nil {
247248
res.SetError(u.ErrCast(), cmds.ErrNormal)
248249
return
@@ -254,12 +255,15 @@ You can now refer to the added file in a gateway, like so:
254255
return
255256
}
256257

257-
if !quiet && !silent {
258-
progress = true
258+
var showProgressbar bool
259+
if prgFound {
260+
showProgressbar = progress
261+
} else if !quiet && !silent {
262+
showProgressbar = true
259263
}
260264

261265
var bar *pb.ProgressBar
262-
if progress {
266+
if showProgressbar {
263267
bar = pb.New64(0).SetUnits(pb.U_BYTES)
264268
bar.ManualUpdate = true
265269
bar.ShowTimeLeft = false
@@ -286,7 +290,7 @@ You can now refer to the added file in a gateway, like so:
286290
}
287291
output := out.(*coreunix.AddedObject)
288292
if len(output.Hash) > 0 {
289-
if progress {
293+
if showProgressbar {
290294
// clear progress bar line before we print "added x" output
291295
fmt.Fprintf(res.Stderr(), "\033[2K\r")
292296
}
@@ -299,7 +303,7 @@ You can now refer to the added file in a gateway, like so:
299303
} else {
300304
log.Debugf("add progress: %v %v\n", output.Name, output.Bytes)
301305

302-
if !progress {
306+
if !showProgressbar {
303307
continue
304308
}
305309

@@ -315,11 +319,11 @@ You can now refer to the added file in a gateway, like so:
315319
totalProgress = bar.Add64(delta)
316320
}
317321

318-
if progress {
322+
if showProgressbar {
319323
bar.Update()
320324
}
321325
case size := <-sizeChan:
322-
if progress {
326+
if showProgressbar {
323327
bar.Total = size
324328
bar.ShowPercent = true
325329
bar.ShowBar = true

0 commit comments

Comments
 (0)