This repository was archived by the owner on Feb 12, 2024. It is now read-only.
File tree 3 files changed +12
-18
lines changed 3 files changed +12
-18
lines changed Original file line number Diff line number Diff line change @@ -203,8 +203,6 @@ module.exports = {
203
203
const ipfs = argv . ipfs
204
204
205
205
let list = [ ]
206
- let currentBytes = 0
207
-
208
206
waterfall ( [
209
207
( next ) => glob ( path . join ( inPath , '/**/*' ) , next ) ,
210
208
( globResult , next ) => {
@@ -216,8 +214,7 @@ module.exports = {
216
214
if ( argv . progress ) {
217
215
const bar = createProgressBar ( totalBytes )
218
216
options . progress = function ( byteLength ) {
219
- currentBytes += byteLength
220
- bar . tick ( byteLength , { progress : byteman ( currentBytes , 2 , 'MB' ) } )
217
+ bar . update ( byteLength / totalBytes , { progress : byteman ( byteLength , 2 , 'MB' ) } )
221
218
}
222
219
}
223
220
Original file line number Diff line number Diff line change @@ -20,6 +20,14 @@ module.exports = function files (self) {
20
20
shardSplitThreshold : self . _options . EXPERIMENTAL . sharding ? 1000 : Infinity
21
21
} , options )
22
22
23
+ let total = 0
24
+ let prog = opts . progress || ( ( ) => { } )
25
+ const progress = ( bytes ) => {
26
+ total += bytes
27
+ prog ( total )
28
+ }
29
+
30
+ opts . progress = progress
23
31
return pull (
24
32
pull . map ( normalizeContent ) ,
25
33
pull . flatten ( ) ,
@@ -65,18 +73,9 @@ module.exports = function files (self) {
65
73
return callback ( new Error ( 'Invalid arguments, data must be an object, Buffer or readable stream' ) )
66
74
}
67
75
68
- let total = 0
69
- let prog = options . progress || ( ( ) => { } )
70
- const progress = ( bytes ) => {
71
- total += bytes
72
- prog ( total )
73
- }
74
-
75
- options . progress = progress
76
76
pull (
77
- pull . values ( normalizeContent ( data ) ) ,
78
- importer ( self . _ipldResolver , options ) ,
79
- pull . asyncMap ( prepareFile . bind ( null , self , options ) ) ,
77
+ pull . values ( [ data ] ) ,
78
+ createAddPullStream ( options ) ,
80
79
sort ( ( a , b ) => {
81
80
if ( a . path < b . path ) return 1
82
81
if ( a . path > b . path ) return - 1
Original file line number Diff line number Diff line change @@ -209,10 +209,8 @@ exports.add = {
209
209
} )
210
210
211
211
const replyStream = pushable ( )
212
- let total = 0
213
212
const progressHandler = ( bytes ) => {
214
- total += bytes
215
- replyStream . push ( { Bytes : total } )
213
+ replyStream . push ( { Bytes : bytes } )
216
214
}
217
215
218
216
const options = {
You can’t perform that action at this time.
0 commit comments