mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-23 19:26:33 +00:00
Deselect the image if the source drive is removed
Change-type: patch
This commit is contained in:
parent
e5ee0f1961
commit
391e4444d4
@ -23,11 +23,13 @@ import * as ReactDOM from 'react-dom';
|
|||||||
import { v4 as uuidV4 } from 'uuid';
|
import { v4 as uuidV4 } from 'uuid';
|
||||||
|
|
||||||
import * as packageJSON from '../../../package.json';
|
import * as packageJSON from '../../../package.json';
|
||||||
|
import { isSourceDrive } from '../../shared/drive-constraints';
|
||||||
import * as EXIT_CODES from '../../shared/exit-codes';
|
import * as EXIT_CODES from '../../shared/exit-codes';
|
||||||
import * as messages from '../../shared/messages';
|
import * as messages from '../../shared/messages';
|
||||||
import * as availableDrives from './models/available-drives';
|
import * as availableDrives from './models/available-drives';
|
||||||
import * as flashState from './models/flash-state';
|
import * as flashState from './models/flash-state';
|
||||||
import { init as ledsInit } from './models/leds';
|
import { init as ledsInit } from './models/leds';
|
||||||
|
import { deselectImage, getImage } from './models/selection-state';
|
||||||
import * as settings from './models/settings';
|
import * as settings from './models/settings';
|
||||||
import { Actions, observe, store } from './models/store';
|
import { Actions, observe, store } from './models/store';
|
||||||
import * as analytics from './modules/analytics';
|
import * as analytics from './modules/analytics';
|
||||||
@ -250,6 +252,15 @@ async function addDrive(drive: Drive) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function removeDrive(drive: Drive) {
|
function removeDrive(drive: Drive) {
|
||||||
|
if (
|
||||||
|
drive instanceof sdk.sourceDestination.BlockDevice &&
|
||||||
|
// @ts-ignore BlockDevice.drive is private
|
||||||
|
isSourceDrive(drive.drive, getImage())
|
||||||
|
) {
|
||||||
|
// Deselect the image if it was on the drive that was removed.
|
||||||
|
// This will also deselect the image if the drive mountpoints change.
|
||||||
|
deselectImage();
|
||||||
|
}
|
||||||
const preparedDrive = prepareDrive(drive);
|
const preparedDrive = prepareDrive(drive);
|
||||||
const drives = getDrives();
|
const drives = getDrives();
|
||||||
delete drives[preparedDrive.device];
|
delete drives[preparedDrive.device];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user