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 <lorenzoa@balena.io>
This commit is contained in:
Lorenzo Alberto Maria Ambrosi 2018-11-22 17:09:35 +01:00
parent b298e53fc4
commit 20996b153d
3 changed files with 13 additions and 13 deletions

View File

@ -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) {

View File

@ -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'
} ],

View File

@ -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:'