This repository has been archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Feat/cli progress bar #1036
Merged
Merged
Feat/cli progress bar #1036
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
bf7e38d
Progress bar for cli
bmordan cb42844
requires async/waterfall in place of async
bmordan d311dc5
adds a test for createProgressBar
bmordan 8ea66f9
feat: add missing progress bar support for http api
dryajov 480896a
feat: add error propagation
dryajov 0a7092d
feat: handle errors as trailer headers
dryajov 50d1d2b
feat: acumulate progress bytes sent for consistency with go
dryajov 6086a72
chore: upgrade to latest interface-ipfs-core
dryajov f953cdb
chore: upgrade ipfs-api to latest
dryajov bd70fbd
fix: send file size along Name and Hash
dryajov d880de5
fix semver
daviddias File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,7 +54,7 @@ module.exports = function files (self) { | |
add: promisify((data, options, callback) => { | ||
if (typeof options === 'function') { | ||
callback = options | ||
options = undefined | ||
options = {} | ||
} else if (!callback || typeof callback !== 'function') { | ||
callback = noop | ||
} | ||
|
@@ -65,6 +65,14 @@ module.exports = function files (self) { | |
return callback(new Error('Invalid arguments, data must be an object, Buffer or readable stream')) | ||
} | ||
|
||
let total = 0 | ||
let prog = options.progress || (() => {}) | ||
const progress = (bytes) => { | ||
total += bytes | ||
prog(total) | ||
} | ||
|
||
options.progress = progress | ||
pull( | ||
pull.values(normalizeContent(data)), | ||
importer(self._ipldResolver, options), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @diasdavid I noticed that there are two entry points for importer, here and above on line 26. The one above, gets called from the HTTP API, this one is called from the regular callback flow, they seem to be be doing exactly the same thing, perhaps we can replace this with a call to |
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* eslint-env mocha */ | ||
'use strict' | ||
|
||
const expect = require('chai').expect | ||
const createProgressBar = require('../../src/cli/utils').createProgressBar | ||
|
||
describe('progress bar', () => { | ||
it('created with the correct properties', () => { | ||
const total = 1000 | ||
|
||
const bar = createProgressBar(total) | ||
expect(bar.total).to.eql(total) | ||
expect(typeof bar.tick).to.eql('function') | ||
}) | ||
}) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dryajov do not change ~ to ^, we use ~ until it gets to 1.0.0