diff --git a/lib/gui/app/os/dialog.ts b/lib/gui/app/os/dialog.ts index aea6b821..ce906265 100644 --- a/lib/gui/app/os/dialog.ts +++ b/lib/gui/app/os/dialog.ts @@ -18,8 +18,21 @@ import * as electron from 'electron'; import * as _ from 'lodash'; import * as errors from '../../../shared/errors'; +import * as settings from '../../../gui/app/models/settings'; import { SUPPORTED_EXTENSIONS } from '../../../shared/supported-formats'; +async function mountSourceDrive() { + // sourceDrivePath is the name of the link in /dev/disk/by-path + const sourceDrivePath = await settings.get('automountOnFileSelect'); + if (sourceDrivePath) { + try { + await electron.ipcRenderer.invoke('mount-drive', sourceDrivePath); + } catch (error) { + // noop + } + } +} + /** * @summary Open an image selection dialog * @@ -27,6 +40,7 @@ import { SUPPORTED_EXTENSIONS } from '../../../shared/supported-formats'; * Notice that by image, we mean *.img/*.iso/*.zip/etc files. */ export async function selectImage(): Promise { + await mountSourceDrive(); const options: electron.OpenDialogOptions = { // This variable is set when running in GNU/Linux from // inside an AppImage, and represents the working directory