Skip to content
This repository was archived by the owner on Aug 12, 2020. It is now read-only.

Adds call to progress bar function #179

Merged
merged 6 commits into from
Sep 5, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ The input's file paths and directory structure will be preserved in the [`dag-pb
- `dirBuilder` (object): the options for the directory builder
- `hamt` (object): the options for the HAMT sharded directory builder
- bits (positive integer, defaults to `8`): the number of bits at each bucket of the HAMT
- `progress` (function): a function that will be called with the byte length of chunks as a file is added to ipfs.

### Exporter

Expand Down
7 changes: 6 additions & 1 deletion src/builder/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,12 @@ module.exports = function (createChunker, ipldResolver, createReducer, _options)
pull(
file.content,
createChunker(options.chunkerOptions),
pull.map(chunk => new Buffer(chunk)),
pull.map(chunk => {
if (options.progress && typeof options.progress === 'function') {
options.progress(chunk.byteLength)
}
return new Buffer(chunk)
}),
pull.map(buffer => new UnixFS('file', buffer)),
pull.asyncMap((fileNode, callback) => {
DAGNode.create(fileNode.marshal(), (err, node) => {
Expand Down