@@ -36,16 +36,17 @@ const (
36
36
37
37
var AddCmd = & cmds.Command {
38
38
Helptext : cmds.HelpText {
39
- Tagline : "Add a file to ipfs." ,
39
+ Tagline : "Add a file or directory to ipfs." ,
40
40
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.
44
42
` ,
45
43
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>.
49
50
50
51
The wrap option, '-w', wraps the file (or files, if using the
51
52
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:
69
70
},
70
71
Options : []cmds.Option {
71
72
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." ),
74
75
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." ),
79
80
cmds .StringOption (chunkerOptionName , "s" , "Chunking algorithm to use." ),
80
81
cmds .BoolOption (pinOptionName , "Pin this object when adding." ).Default (true ),
81
82
},
@@ -242,7 +243,7 @@ You can now refer to the added file in a gateway, like so:
242
243
return
243
244
}
244
245
245
- progress , _ , err := req .Option (progressOptionName ).Bool ()
246
+ progress , prgFound , err := req .Option (progressOptionName ).Bool ()
246
247
if err != nil {
247
248
res .SetError (u .ErrCast (), cmds .ErrNormal )
248
249
return
@@ -254,12 +255,15 @@ You can now refer to the added file in a gateway, like so:
254
255
return
255
256
}
256
257
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
259
263
}
260
264
261
265
var bar * pb.ProgressBar
262
- if progress {
266
+ if showProgressbar {
263
267
bar = pb .New64 (0 ).SetUnits (pb .U_BYTES )
264
268
bar .ManualUpdate = true
265
269
bar .ShowTimeLeft = false
@@ -286,7 +290,7 @@ You can now refer to the added file in a gateway, like so:
286
290
}
287
291
output := out .(* coreunix.AddedObject )
288
292
if len (output .Hash ) > 0 {
289
- if progress {
293
+ if showProgressbar {
290
294
// clear progress bar line before we print "added x" output
291
295
fmt .Fprintf (res .Stderr (), "\033 [2K\r " )
292
296
}
@@ -299,7 +303,7 @@ You can now refer to the added file in a gateway, like so:
299
303
} else {
300
304
log .Debugf ("add progress: %v %v\n " , output .Name , output .Bytes )
301
305
302
- if ! progress {
306
+ if ! showProgressbar {
303
307
continue
304
308
}
305
309
@@ -315,11 +319,11 @@ You can now refer to the added file in a gateway, like so:
315
319
totalProgress = bar .Add64 (delta )
316
320
}
317
321
318
- if progress {
322
+ if showProgressbar {
319
323
bar .Update ()
320
324
}
321
325
case size := <- sizeChan :
322
- if progress {
326
+ if showProgressbar {
323
327
bar .Total = size
324
328
bar .ShowPercent = true
325
329
bar .ShowBar = true
0 commit comments