From a6ec66d0b334a3cf3f4506208818b05bad333081 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Mon, 23 Nov 2015 13:28:15 -0400 Subject: [PATCH] Pass the whole drive object to the writer Currently we only pass the drive device. By passing all the object (containing the mountpoint, size, etc) we allow more control to the writer in how to treat the device before/during/after the burning process. --- build/browser/app.js | 24 +++++++++++++++--------- lib/browser/app.js | 4 ++-- lib/browser/modules/image-writer.js | 12 ++++++++---- lib/browser/modules/selection-state.js | 8 +++++--- lib/index.html | 4 ++-- lib/src/writer.js | 12 +++++++----- 6 files changed, 39 insertions(+), 25 deletions(-) diff --git a/build/browser/app.js b/build/browser/app.js index b9c0f7c4..46bf9bb5 100644 --- a/build/browser/app.js +++ b/build/browser/app.js @@ -65,7 +65,7 @@ app.controller('AppController', function($q, DriveScannerService, SelectionState this.selectDrive = function(drive) { self.selection.setDrive(drive); - console.debug('Drive selected: ' + drive); + console.debug('Drive selected: ' + drive.device); }; this.platform = window.process.platform; @@ -76,7 +76,7 @@ app.controller('AppController', function($q, DriveScannerService, SelectionState // otherwise Windows throws EPERM self.scanner.stop(); - console.debug('Burning ' + image + ' to ' + drive); + console.debug('Burning ' + image + ' to ' + drive.device); return self.writer.burn(image, drive).then(function() { console.debug('Done!'); }); @@ -371,13 +371,15 @@ imageWriter.service('ImageWriterService', function($q, $timeout) { * This function is extracted for testing purposes. * * @param {String} image - image path - * @param {String} drive - drive device + * @param {Object} drive - drive * @param {Function} onProgress - in progress callback (state) * * @returns {Promise} * * @example - * ImageWriter.performWrite('path/to/image.img', '/dev/disk2', function(state) { + * ImageWriter.performWrite('path/to/image.img', { + * device: '/dev/disk2' + * }, function(state) { * console.log(state.percentage); * }); */ @@ -394,12 +396,14 @@ imageWriter.service('ImageWriterService', function($q, $timeout) { * This function will update `.progress` with the current writing percentage. * * @param {String} image - image path - * @param {String} drive - drive device + * @param {Object} drive - drive * * @returns {Promise} * * @example - * ImageWriterService.burn('foo.img', '/dev/disk').then(function() { + * ImageWriterService.burn('foo.img', { + * device: '/dev/disk2' + * }).then(function() { * console.log('Write completed!'); * }); */ @@ -520,10 +524,12 @@ selectionState.service('SelectionStateService', function() { * @function * @public * - * @param {String} drive - drive + * @param {Object} drive - drive * * @example - * SelectionStateService.setDrive('/dev/disk2'); + * SelectionStateService.setDrive({ + * device: '/dev/disk2' + * }); */ this.setDrive = function(drive) { selection.drive = drive; @@ -548,7 +554,7 @@ selectionState.service('SelectionStateService', function() { * @function * @public * - * @returns {String} drive + * @returns {Object} drive * * @example * var drive = SelectionStateService.getDrive(); diff --git a/lib/browser/app.js b/lib/browser/app.js index 1d48af9b..f8226494 100644 --- a/lib/browser/app.js +++ b/lib/browser/app.js @@ -64,7 +64,7 @@ app.controller('AppController', function($q, DriveScannerService, SelectionState this.selectDrive = function(drive) { self.selection.setDrive(drive); - console.debug('Drive selected: ' + drive); + console.debug('Drive selected: ' + drive.device); }; this.platform = window.process.platform; @@ -75,7 +75,7 @@ app.controller('AppController', function($q, DriveScannerService, SelectionState // otherwise Windows throws EPERM self.scanner.stop(); - console.debug('Burning ' + image + ' to ' + drive); + console.debug('Burning ' + image + ' to ' + drive.device); return self.writer.burn(image, drive).then(function() { console.debug('Done!'); }); diff --git a/lib/browser/modules/image-writer.js b/lib/browser/modules/image-writer.js index 56edfa77..6f9a487d 100644 --- a/lib/browser/modules/image-writer.js +++ b/lib/browser/modules/image-writer.js @@ -108,13 +108,15 @@ imageWriter.service('ImageWriterService', function($q, $timeout) { * This function is extracted for testing purposes. * * @param {String} image - image path - * @param {String} drive - drive device + * @param {Object} drive - drive * @param {Function} onProgress - in progress callback (state) * * @returns {Promise} * * @example - * ImageWriter.performWrite('path/to/image.img', '/dev/disk2', function(state) { + * ImageWriter.performWrite('path/to/image.img', { + * device: '/dev/disk2' + * }, function(state) { * console.log(state.percentage); * }); */ @@ -131,12 +133,14 @@ imageWriter.service('ImageWriterService', function($q, $timeout) { * This function will update `.progress` with the current writing percentage. * * @param {String} image - image path - * @param {String} drive - drive device + * @param {Object} drive - drive * * @returns {Promise} * * @example - * ImageWriterService.burn('foo.img', '/dev/disk').then(function() { + * ImageWriterService.burn('foo.img', { + * device: '/dev/disk2' + * }).then(function() { * console.log('Write completed!'); * }); */ diff --git a/lib/browser/modules/selection-state.js b/lib/browser/modules/selection-state.js index 56ad549c..507ddb68 100644 --- a/lib/browser/modules/selection-state.js +++ b/lib/browser/modules/selection-state.js @@ -45,10 +45,12 @@ selectionState.service('SelectionStateService', function() { * @function * @public * - * @param {String} drive - drive + * @param {Object} drive - drive * * @example - * SelectionStateService.setDrive('/dev/disk2'); + * SelectionStateService.setDrive({ + * device: '/dev/disk2' + * }); */ this.setDrive = function(drive) { selection.drive = drive; @@ -73,7 +75,7 @@ selectionState.service('SelectionStateService', function() { * @function * @public * - * @returns {String} drive + * @returns {Object} drive * * @example * var drive = SelectionStateService.getDrive(); diff --git a/lib/index.html b/lib/index.html index ca5f4ce0..2c1c82b5 100644 --- a/lib/index.html +++ b/lib/index.html @@ -54,7 +54,7 @@