mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-23 11:16:39 +00:00
feat(cli): Display number of active cards
Change-Type: patch
This commit is contained in:
parent
c724e4cb20
commit
ef634227aa
@ -87,7 +87,7 @@ permissions.isElevated().then((elevated) => {
|
|||||||
*/
|
*/
|
||||||
const onProgress = (state) => {
|
const onProgress = (state) => {
|
||||||
state.message = state.active > 1
|
state.message = state.active > 1
|
||||||
? `${bytes(state.totalSpeed)}/s total, ${bytes(state.speed)}/s avg`
|
? `${bytes(state.totalSpeed)}/s total, ${bytes(state.speed)}/s x ${state.active}`
|
||||||
: `${bytes(state.totalSpeed)}/s`
|
: `${bytes(state.totalSpeed)}/s`
|
||||||
|
|
||||||
state.message = `${state.type === 'write' ? 'Flashing' : 'Validating'}: ${state.message}`
|
state.message = `${state.type === 'write' ? 'Flashing' : 'Validating'}: ${state.message}`
|
||||||
|
@ -41,11 +41,11 @@ const errors = require('../../shared/errors')
|
|||||||
const DEFAULT_EXT = 'img'
|
const DEFAULT_EXT = 'img'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @summary Default read-stream highWaterMark value (4M)
|
* @summary Default read-stream highWaterMark value (1M)
|
||||||
* @type {Number}
|
* @type {Number}
|
||||||
* @constant
|
* @constant
|
||||||
*/
|
*/
|
||||||
const STREAM_HWM = 4194304
|
const STREAM_HWM = 1048576
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @summary Image handlers
|
* @summary Image handlers
|
||||||
|
@ -375,6 +375,46 @@ class ImageWriter extends EventEmitter {
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @summary Internal progress state handler
|
||||||
|
* @param {Object} state - progress state
|
||||||
|
* @example
|
||||||
|
* pipeline.on('progress', (state) => {
|
||||||
|
* // ...
|
||||||
|
* this._onProgress(state)
|
||||||
|
* })
|
||||||
|
*/
|
||||||
|
_onProgress (state) {
|
||||||
|
state.totalSpeed = 0
|
||||||
|
state.active = 0
|
||||||
|
|
||||||
|
state.flashing = 0
|
||||||
|
state.verifying = 0
|
||||||
|
state.failed = 0
|
||||||
|
state.succeeded = 0
|
||||||
|
|
||||||
|
this.destinations.forEach((dest) => {
|
||||||
|
state.flashing += !dest.error && !dest.finished ? 1 : 0
|
||||||
|
state.verifying += !dest.error && !dest.verified ? 1 : 0
|
||||||
|
state.failed += dest.error ? 1 : 0
|
||||||
|
if (!(dest.finished && dest.verified) && !dest.error) {
|
||||||
|
state.totalSpeed += state.type === 'write'
|
||||||
|
? dest.stream.speed
|
||||||
|
: dest.progress.state.speed
|
||||||
|
state.active += 1
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
state.speed = state.active
|
||||||
|
? state.totalSpeed / state.active
|
||||||
|
: state.active
|
||||||
|
|
||||||
|
state.succeeded = state.active - state.failed - state.flashing - state.verifying
|
||||||
|
state.eta = state.speed ? state.remaining / state.speed : 0
|
||||||
|
|
||||||
|
this.emit('progress', state)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @summary Start the writing process
|
* @summary Start the writing process
|
||||||
* @returns {ImageWriter} imageWriter
|
* @returns {ImageWriter} imageWriter
|
||||||
@ -438,18 +478,7 @@ class ImageWriter extends EventEmitter {
|
|||||||
|
|
||||||
progressStream.on('progress', (state) => {
|
progressStream.on('progress', (state) => {
|
||||||
state.type = 'check'
|
state.type = 'check'
|
||||||
state.totalSpeed = 0
|
this._onProgress(state)
|
||||||
state.active = 0
|
|
||||||
this.destinations.forEach((destination) => {
|
|
||||||
if (!destination.verified && !destination.error) {
|
|
||||||
state.totalSpeed += destination.progress.state.speed
|
|
||||||
state.active += 1
|
|
||||||
}
|
|
||||||
})
|
|
||||||
state.speed = state.active
|
|
||||||
? state.totalSpeed / state.active
|
|
||||||
: state.active
|
|
||||||
this.emit('progress', state)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
this.destinations.forEach((destination) => {
|
this.destinations.forEach((destination) => {
|
||||||
@ -681,18 +710,7 @@ class ImageWriter extends EventEmitter {
|
|||||||
// Pipeline.bind(progressStream, 'progress');
|
// Pipeline.bind(progressStream, 'progress');
|
||||||
progressStream.on('progress', (state) => {
|
progressStream.on('progress', (state) => {
|
||||||
state.type = 'write'
|
state.type = 'write'
|
||||||
state.totalSpeed = 0
|
this._onProgress(state)
|
||||||
state.active = 0
|
|
||||||
this.destinations.forEach((destination) => {
|
|
||||||
if (!destination.finished && !destination.error) {
|
|
||||||
state.totalSpeed += destination.stream.speed
|
|
||||||
state.active += 1
|
|
||||||
}
|
|
||||||
})
|
|
||||||
state.speed = state.active
|
|
||||||
? state.totalSpeed / state.active
|
|
||||||
: state.active
|
|
||||||
this.emit('progress', state)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
pipeline.bind(this.source.stream, 'error')
|
pipeline.bind(this.source.stream, 'error')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user