mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-18 16:56:32 +00:00
Merge pull request #176 from resin-io/feat/auto-unmount-setting
Add a setting to disable auto-unmount on success
This commit is contained in:
commit
dbb4ee6a5a
@ -207,7 +207,9 @@ app.controller('NavigationController', function($state) {
|
|||||||
this.isState = $state.is;
|
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) {
|
this.restart = function(options) {
|
||||||
SelectionStateService.clear(options);
|
SelectionStateService.clear(options);
|
||||||
$state.go('main');
|
$state.go('main');
|
||||||
|
@ -29,9 +29,12 @@ if (window.mocha) {
|
|||||||
var writer = electron.remote.require('./src/writer');
|
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 self = this;
|
||||||
let burning = false;
|
let burning = false;
|
||||||
|
|
||||||
@ -90,7 +93,7 @@ imageWriter.service('ImageWriterService', function($q, $timeout) {
|
|||||||
* });
|
* });
|
||||||
*/
|
*/
|
||||||
this.performWrite = function(image, drive, onProgress) {
|
this.performWrite = function(image, drive, onProgress) {
|
||||||
return $q.when(writer.writeImage(image, drive, onProgress));
|
return $q.when(writer.writeImage(image, drive, SettingsService.data, onProgress));
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,7 +35,8 @@ settings.service('SettingsService', function($localStorage) {
|
|||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
this.data = $localStorage.$default({
|
this.data = $localStorage.$default({
|
||||||
errorReporting: true
|
errorReporting: true,
|
||||||
|
unmountOnSuccess: true
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -7,4 +7,11 @@
|
|||||||
<span>Enable error reporting</span>
|
<span>Enable error reporting</span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="checkbox">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" ng-model="settings.storage.unmountOnSuccess">
|
||||||
|
<span>Enable auto-unmounting on success</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<div class="col-xs">
|
<div class="col-xs">
|
||||||
<div class="box text-center">
|
<div class="box text-center">
|
||||||
<h3><hero-tick type="success" class="space-right-tiny"></hero-tick> Burn Complete!</h3>
|
<h3><hero-tick type="success" class="space-right-tiny"></hero-tick> Burn Complete!</h3>
|
||||||
<p class="soft">Safely ejected and ready for use</p>
|
<p ng-show="finish.settings.unmountOnSuccess" class="soft">Safely ejected and ready for use</p>
|
||||||
|
|
||||||
<div class="row center-xs space-vertical-large">
|
<div class="row center-xs space-vertical-large">
|
||||||
<div class="col-xs-4 space-medium">
|
<div class="col-xs-4 space-medium">
|
||||||
|
@ -59,6 +59,8 @@ exports.getImageStream = function(image) {
|
|||||||
*
|
*
|
||||||
* @param {String} image - path to image
|
* @param {String} image - path to image
|
||||||
* @param {Object} drive - drive
|
* @param {Object} drive - drive
|
||||||
|
* @param {Object} options - options
|
||||||
|
* @param {Boolean} [options.unmountOnSuccess=false] - unmount on success
|
||||||
* @param {Function} onProgress - on progress callback (state)
|
* @param {Function} onProgress - on progress callback (state)
|
||||||
*
|
*
|
||||||
* @returns {Promise}
|
* @returns {Promise}
|
||||||
@ -66,13 +68,15 @@ exports.getImageStream = function(image) {
|
|||||||
* @example
|
* @example
|
||||||
* writer.writeImage('path/to/image.img', {
|
* writer.writeImage('path/to/image.img', {
|
||||||
* device: '/dev/disk2'
|
* device: '/dev/disk2'
|
||||||
|
* }, {
|
||||||
|
* unmountOnSuccess: true
|
||||||
* }, function(state) {
|
* }, function(state) {
|
||||||
* console.log(state.percentage);
|
* console.log(state.percentage);
|
||||||
* }).then(function() {
|
* }).then(function() {
|
||||||
* console.log('Done!');
|
* console.log('Done!');
|
||||||
* });
|
* });
|
||||||
*/
|
*/
|
||||||
exports.writeImage = function(image, drive, onProgress) {
|
exports.writeImage = function(image, drive, options, onProgress) {
|
||||||
return umount.umountAsync(drive.device).then(function() {
|
return umount.umountAsync(drive.device).then(function() {
|
||||||
let stream = exports.getImageStream(image);
|
let stream = exports.getImageStream(image);
|
||||||
return imageWrite.write(drive.device, stream);
|
return imageWrite.write(drive.device, stream);
|
||||||
@ -83,6 +87,10 @@ exports.writeImage = function(image, drive, onProgress) {
|
|||||||
writer.on('done', resolve);
|
writer.on('done', resolve);
|
||||||
});
|
});
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
|
if (!options.unmountOnSuccess) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (isWindows && drive.mountpoint) {
|
if (isWindows && drive.mountpoint) {
|
||||||
return removedrive.ejectAsync(drive.mountpoint);
|
return removedrive.ejectAsync(drive.mountpoint);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user