From 1c52379ee3da40306ae2c14751f9026d59e7a6c3 Mon Sep 17 00:00:00 2001 From: Alexis Svinartchouk Date: Mon, 9 Nov 2020 16:58:18 +0100 Subject: [PATCH] Add drivesOrder setting Change-type: patch --- lib/gui/app/models/store.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/gui/app/models/store.ts b/lib/gui/app/models/store.ts index ee4a8ae7..f167dfa9 100644 --- a/lib/gui/app/models/store.ts +++ b/lib/gui/app/models/store.ts @@ -16,6 +16,7 @@ import * as Immutable from 'immutable'; import * as _ from 'lodash'; +import { basename } from 'path'; import * as redux from 'redux'; import { v4 as uuidV4 } from 'uuid'; @@ -133,11 +134,16 @@ function storeReducer( }); } + // Drives order is a list of devicePaths + const drivesOrder = settings.getSync('drivesOrder') ?? []; + drives = _.sortBy(drives, [ // System drives last (d) => !!d.isSystem, // Devices with no devicePath first (usbboot) (d) => !!d.devicePath, + // Sort as defined in the drivesOrder setting if there is one (only for Linux with udev) + (d) => drivesOrder.indexOf(basename(d.devicePath || '')), // Then sort by devicePath (only available on Linux with udev) or device (d) => d.devicePath || d.device, ]);