fix(writer): Fix writer progress state values

This force-defaults the individual stream speeds to zero,
in order to avoid null values when not available yet.

Change-Type: patch
This commit is contained in:
Jonas Hermsmeier 2018-04-05 21:51:00 +02:00
parent 64604dbcc6
commit f119ca683e
No known key found for this signature in database
GPG Key ID: 1B870F801A0CEE9F
2 changed files with 4 additions and 3 deletions

View File

@ -400,15 +400,15 @@ class ImageWriter extends EventEmitter {
state.succeeded += !dest.error && dest.finished && (dest.verified || !this.verifyChecksums) ? 1 : 0
if (!(dest.finished && dest.verified) && !dest.error) {
state.totalSpeed += state.type === 'write'
? dest.stream.speed
: dest.progress.state.speed
? (dest.stream.speed || 0)
: (dest.progress.state.speed || 0)
state.active += 1
}
})
state.speed = state.active
? state.totalSpeed / state.active
: state.active
: state.totalSpeed
state.eta = state.speed ? state.remaining / state.speed : 0

View File

@ -56,6 +56,7 @@ class ProgressStream extends Stream.Transform {
remaining: 0,
runtime: 0,
speed: 0,
totalSpeed: 0,
transferred: 0
}