diff --git a/lib/browser/app.js b/lib/browser/app.js index 1f942417..42f60ecd 100644 --- a/lib/browser/app.js +++ b/lib/browser/app.js @@ -207,7 +207,9 @@ app.controller('NavigationController', function($state) { this.isState = $state.is; }); -app.controller('FinishController', function($state, SelectionStateService) { +app.controller('FinishController', function($state, SelectionStateService, SettingsService) { + this.settings = SettingsService.data; + this.restart = function(options) { SelectionStateService.clear(options); $state.go('main'); diff --git a/lib/browser/modules/image-writer.js b/lib/browser/modules/image-writer.js index efecc2d5..c87aaec9 100644 --- a/lib/browser/modules/image-writer.js +++ b/lib/browser/modules/image-writer.js @@ -29,9 +29,12 @@ if (window.mocha) { var writer = electron.remote.require('./src/writer'); } -const imageWriter = angular.module('Etcher.image-writer', []); +require('./settings'); +const imageWriter = angular.module('Etcher.image-writer', [ + 'Etcher.settings' +]); -imageWriter.service('ImageWriterService', function($q, $timeout) { +imageWriter.service('ImageWriterService', function($q, $timeout, SettingsService) { let self = this; let burning = false; @@ -90,7 +93,7 @@ imageWriter.service('ImageWriterService', function($q, $timeout) { * }); */ this.performWrite = function(image, drive, onProgress) { - return $q.when(writer.writeImage(image, drive, onProgress)); + return $q.when(writer.writeImage(image, drive, SettingsService.data, onProgress)); }; /** diff --git a/lib/browser/modules/settings.js b/lib/browser/modules/settings.js index 4089b997..907c7271 100644 --- a/lib/browser/modules/settings.js +++ b/lib/browser/modules/settings.js @@ -35,7 +35,8 @@ settings.service('SettingsService', function($localStorage) { * @public */ this.data = $localStorage.$default({ - errorReporting: true + errorReporting: true, + unmountOnSuccess: true }); }); diff --git a/lib/partials/settings.html b/lib/partials/settings.html index 9c9c0d1f..f08bebdc 100644 --- a/lib/partials/settings.html +++ b/lib/partials/settings.html @@ -7,4 +7,11 @@ Enable error reporting + +
+ +
diff --git a/lib/partials/success.html b/lib/partials/success.html index 51dd90d3..1ca2a5ef 100644 --- a/lib/partials/success.html +++ b/lib/partials/success.html @@ -2,7 +2,7 @@

Burn Complete!

-

Safely ejected and ready for use

+

Safely ejected and ready for use

diff --git a/lib/src/writer.js b/lib/src/writer.js index 13066245..ac24fda1 100644 --- a/lib/src/writer.js +++ b/lib/src/writer.js @@ -59,6 +59,8 @@ exports.getImageStream = function(image) { * * @param {String} image - path to image * @param {Object} drive - drive + * @param {Object} options - options + * @param {Boolean} [options.unmountOnSuccess=false] - unmount on success * @param {Function} onProgress - on progress callback (state) * * @returns {Promise} @@ -66,13 +68,15 @@ exports.getImageStream = function(image) { * @example * writer.writeImage('path/to/image.img', { * device: '/dev/disk2' + * }, { + * unmountOnSuccess: true * }, function(state) { * console.log(state.percentage); * }).then(function() { * console.log('Done!'); * }); */ -exports.writeImage = function(image, drive, onProgress) { +exports.writeImage = function(image, drive, options, onProgress) { return umount.umountAsync(drive.device).then(function() { let stream = exports.getImageStream(image); return imageWrite.write(drive.device, stream); @@ -83,6 +87,10 @@ exports.writeImage = function(image, drive, onProgress) { writer.on('done', resolve); }); }).then(function() { + if (!options.unmountOnSuccess) { + return; + } + if (isWindows && drive.mountpoint) { return removedrive.ejectAsync(drive.mountpoint); }