diff --git a/lib/gui/app/modules/image-writer.js b/lib/gui/app/modules/image-writer.js index ec38ebbf..026012b8 100644 --- a/lib/gui/app/modules/image-writer.js +++ b/lib/gui/app/modules/image-writer.js @@ -126,12 +126,7 @@ exports.performWrite = (image, drives, onProgress) => { console.log(message) }) - const flashResults = { - devices: { - succeeded: 0, - failed: 0 - } - } + const flashResults = {} ipc.server.on('fail', (error) => { console.log('Fail:', error) @@ -144,11 +139,7 @@ exports.performWrite = (image, drives, onProgress) => { _.merge(flashResults, event) }) - ipc.server.on('state', (progress) => { - flashResults.devices.succeeded = progress.succeeded - flashResults.devices.failed = progress.failed - onProgress(progress) - }) + ipc.server.on('state', onProgress) ipc.server.on('ready', (data, socket) => { ipc.server.emit(socket, 'write', { diff --git a/lib/gui/app/pages/finish/templates/success.tpl.html b/lib/gui/app/pages/finish/templates/success.tpl.html index 0a47aff7..87eba293 100644 --- a/lib/gui/app/pages/finish/templates/success.tpl.html +++ b/lib/gui/app/pages/finish/templates/success.tpl.html @@ -6,7 +6,7 @@

Flash Complete!

+ ng-repeat="(type, quantity) in finish.flash.getFlashResults().results.devices"> {{ quantity }} {{ finish.progressMessage[type](quantity) }} diff --git a/lib/sdk/writer/index.js b/lib/sdk/writer/index.js index 14a0c184..c30a6783 100644 --- a/lib/sdk/writer/index.js +++ b/lib/sdk/writer/index.js @@ -350,6 +350,7 @@ class ImageWriter extends EventEmitter { // Generate preparation tasks for all destinations const tasks = destinations.map((destination) => { + destination.verified = !this.verifyChecksums this.destinations.set(destination.device.device, destination) return (next) => { runSeries([ @@ -632,17 +633,27 @@ class ImageWriter extends EventEmitter { */ _finish () { this._cleanup(() => { + const failures = [] + let succeeded = 0 + let failed = 0 + this.finished = true + + this.destinations.forEach((dest) => { + succeeded += dest.finished && dest.verified && !dest.error ? 1 : 0 + failed += dest.error ? 1 : 0 + if (dest.error) { + dest.error.device = dest.device.device + failures.push(dest.error) + } + }) + this.emit('finish', { + devices: { succeeded, failed }, bytesRead: this.bytesRead, bytesWritten: this.bytesWritten, checksum: this.checksum, - errors: Array.from(this.destinations).filter(([ device, dest ]) => { - return dest.error - }).map(([ device, dest ]) => { - dest.error.device = device - return dest.error - }) + errors: failures }) }) }