From 20996b153d3977c1bd78d1b505f044c9d86c9a73 Mon Sep 17 00:00:00 2001 From: Lorenzo Alberto Maria Ambrosi Date: Thu, 22 Nov 2018 17:09:35 +0100 Subject: [PATCH] fix(GUI): Reject drives with null size Change-type: patch Changelog-entry: Reject drives with null size (fixes pretty-bytes error) Signed-off-by: Lorenzo Alberto Maria Ambrosi --- lib/sdk/adapters/blockdevice/index.js | 2 +- tests/gui/models/available-drives.spec.js | 4 ++-- tests/gui/modules/drive-scanner.spec.js | 20 ++++++++++---------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/sdk/adapters/blockdevice/index.js b/lib/sdk/adapters/blockdevice/index.js index 208b2221..ad462b30 100644 --- a/lib/sdk/adapters/blockdevice/index.js +++ b/lib/sdk/adapters/blockdevice/index.js @@ -92,7 +92,7 @@ class BlockDeviceAdapter extends EventEmitter { if (drive.busType === 'RAID') { return false } - return !drive.error && (options.includeSystemDrives || !drive.isSystem) + return !drive.error && Number.isFinite(drive.size) && (options.includeSystemDrives || !drive.isSystem) }).map((drive) => { drive.displayName = drive.device if (/PhysicalDrive/i.test(drive.device) && drive.mountpoints.length) { diff --git a/tests/gui/models/available-drives.spec.js b/tests/gui/models/available-drives.spec.js index 28a8a194..06f78bcb 100644 --- a/tests/gui/models/available-drives.spec.js +++ b/tests/gui/models/available-drives.spec.js @@ -65,7 +65,7 @@ describe('Model: availableDrives', function () { { device: '/dev/sdb', description: 'Foo', - size: '14G', + size: 14000000000, mountpoints: [ { path: '/mnt/foo' } ], @@ -82,7 +82,7 @@ describe('Model: availableDrives', function () { { device: '/dev/sdb', description: 'Foo', - size: '14G', + size: 14000000000, mountpoints: [ { path: '/mnt/foo' } ], diff --git a/tests/gui/modules/drive-scanner.spec.js b/tests/gui/modules/drive-scanner.spec.js index 199f3403..626a1d35 100644 --- a/tests/gui/modules/drive-scanner.spec.js +++ b/tests/gui/modules/drive-scanner.spec.js @@ -118,7 +118,7 @@ describe('Browser: driveScanner', function () { device: '/dev/sdb', displayName: '/dev/sdb', description: 'Foo', - size: '14G', + size: 14000000000, mountpoints: [ { path: '/mnt/foo' @@ -131,7 +131,7 @@ describe('Browser: driveScanner', function () { device: '/dev/sdc', displayName: '/dev/sdc', description: 'Bar', - size: '14G', + size: 14000000000, mountpoints: [ { path: '/mnt/bar' @@ -158,7 +158,7 @@ describe('Browser: driveScanner', function () { device: '/dev/sdb', displayName: '/dev/sdb', description: 'Foo', - size: '14G', + size: 14000000000, mountpoints: [ { path: '/mnt/foo' @@ -172,7 +172,7 @@ describe('Browser: driveScanner', function () { device: '/dev/sdc', displayName: '/dev/sdc', description: 'Bar', - size: '14G', + size: 14000000000, mountpoints: [ { path: '/mnt/bar' @@ -230,7 +230,7 @@ describe('Browser: driveScanner', function () { device: '\\\\.\\PHYSICALDRIVE2', displayName: '\\\\.\\PHYSICALDRIVE2', description: 'Foo', - size: '14G', + size: 14000000000, mountpoints: [], isSystem: false, isRemovable: false @@ -239,7 +239,7 @@ describe('Browser: driveScanner', function () { device: '\\\\.\\PHYSICALDRIVE3', displayName: 'F:', description: 'Bar', - size: '14G', + size: 14000000000, mountpoints: [ { path: 'F:' @@ -266,7 +266,7 @@ describe('Browser: driveScanner', function () { device: '\\\\.\\PHYSICALDRIVE2', displayName: '\\\\.\\PHYSICALDRIVE2', description: 'Foo', - size: '14G', + size: 14000000000, mountpoints: [], adapter: 'blockdevice', isSystem: false, @@ -276,7 +276,7 @@ describe('Browser: driveScanner', function () { device: '\\\\.\\PHYSICALDRIVE3', displayName: 'F:', description: 'Bar', - size: '14G', + size: 14000000000, mountpoints: [ { path: 'F:' @@ -309,7 +309,7 @@ describe('Browser: driveScanner', function () { device: '\\\\.\\PHYSICALDRIVE3', raw: '\\\\.\\PHYSICALDRIVE3', description: 'Bar', - size: '14G', + size: 14000000000, mountpoints: [ { path: 'F:' @@ -355,7 +355,7 @@ describe('Browser: driveScanner', function () { device: '\\\\.\\PHYSICALDRIVE3', raw: '\\\\.\\PHYSICALDRIVE3', description: 'Bar', - size: '14G', + size: 14000000000, mountpoints: [ { path: 'F:'