fix(GUI): don't auto select system drives in unsafe mode

Currently Etcher will auto-select a system drive if its the only
available one when the "unsafe mode" is enabled, which doesn't feel
right.

Change-Type: patch
Changelog-Entry: Don't auto select system drives in unsafe mode.
See: https://github.com/resin-io/etcher/pull/1061
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
This commit is contained in:
Juan Cruz Viotti 2017-01-31 13:03:12 -04:00
parent 53ea89782c
commit 70c7ddc52a
2 changed files with 23 additions and 1 deletions

View File

@ -101,7 +101,12 @@ const storeReducer = (state, action) => {
if (_.every([
constraints.isDriveValid(drive, image),
constraints.isDriveSizeRecommended(drive, image)
constraints.isDriveSizeRecommended(drive, image),
// We don't want to auto-select system drives,
// even when "unsafe mode" is enabled
!constraints.isSystemDrive(drive)
])) {
return storeReducer(newState, {
type: ACTIONS.SELECT_DRIVE,

View File

@ -248,6 +248,23 @@ describe('Browser: DrivesModel', function() {
m.chai.expect(SelectionStateModel.hasDrive()).to.be.false;
});
it('should not auto-select a single system drive', function() {
m.chai.expect(SelectionStateModel.hasDrive()).to.be.false;
DrivesModel.setDrives([
{
device: '/dev/sdb',
name: 'Foo',
size: 2000000000,
mountpoint: '/mnt/foo',
system: true,
protected: false
}
]);
m.chai.expect(SelectionStateModel.hasDrive()).to.be.false;
});
});
});