Skip to content

Commit

Permalink
fix: filter sizes array for only rw ones
Browse files Browse the repository at this point in the history
fixes #1008
  • Loading branch information
MauriceNino committed Jan 18, 2024
1 parent 7d6b717 commit e031e35
Show file tree
Hide file tree
Showing 4 changed files with 210 additions and 2 deletions.
8 changes: 8 additions & 0 deletions apps/server/__TESTS__/dynamic-info.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
TEST_CASE_22,
TEST_CASE_23,
TEST_CASE_24,
TEST_CASE_25,
TestCase,
} from './test-cases';

Expand Down Expand Up @@ -106,5 +107,12 @@ describe('Dynamic Info', () => {
).getMappedLayout();
expect(output).to.deep.equal(TEST_CASE_24.output);
});
it('Test Case 25', () => {
const output = new DynamicStorageMapper(
false,
...toStorageInp(TEST_CASE_25)
).getMappedLayout();
expect(output).to.deep.equal(TEST_CASE_25.output);
});
});
});
5 changes: 5 additions & 0 deletions apps/server/__TESTS__/static-info.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
TEST_CASE_22,
TEST_CASE_23,
TEST_CASE_24,
TEST_CASE_25,
TestCase,
} from './test-cases';

Expand Down Expand Up @@ -74,5 +75,9 @@ describe('Static Info', () => {
const output = mapToStorageLayout(false, ...toStorageInp(TEST_CASE_24));
expect(output).to.deep.equal(TEST_CASE_24.layout);
});
it('Test Case 25', () => {
const output = mapToStorageLayout(false, ...toStorageInp(TEST_CASE_25));
expect(output).to.deep.equal(TEST_CASE_25.layout);
});
});
});
194 changes: 194 additions & 0 deletions apps/server/__TESTS__/test-cases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4128,3 +4128,197 @@ export const TEST_CASE_24 = {
],
output: [11911135232],
} as any as TestCase;

// https://github.com/MauriceNino/dashdot/issues/1008#issuecomment-1898024021
export const TEST_CASE_25 = {
disks: [
{
device: '/dev/sda',
type: 'SSD',
name: 'K2 ',
vendor: 'ATA',
size: 120034123776,
bytesPerSector: null,
totalCylinders: null,
totalHeads: null,
totalSectors: null,
totalTracks: null,
tracksPerCylinder: null,
sectorsPerTrack: null,
firmwareRevision: '0807',
serialNum: '',
interfaceType: 'SATA',
smartStatus: 'unknown',
temperature: null,
},
{
device: '/dev/sdb',
type: 'HD',
name: 'USB 3.0 Destop H',
vendor: 'ASMT',
size: 1000204886016,
bytesPerSector: null,
totalCylinders: null,
totalHeads: null,
totalSectors: null,
totalTracks: null,
tracksPerCylinder: null,
sectorsPerTrack: null,
firmwareRevision: '0',
serialNum: '',
interfaceType: 'USB',
smartStatus: 'unknown',
temperature: null,
},
],
sizes: [
{
fs: 'overlay',
type: 'overlay',
size: 116541034496,
used: 39132753920,
available: 71441047552,
use: 35.39,
mount: '/',
rw: false,
},
{
fs: '/dev/sda1',
type: 'ext4',
size: 116541034496,
used: 39132753920,
available: 71441047552,
use: 35.39,
mount: '/mnt/host',
rw: true,
},
{
fs: 'systemd-1',
type: 'autofs',
size: 983351140352,
used: 745736282112,
available: 187587837952,
use: 79.9,
mount: '/mnt/host/media/usb',
rw: false,
},
{
fs: '/dev/sdb',
type: 'ext4',
size: 983351140352,
used: 745736282112,
available: 187587837952,
use: 79.9,
mount: '/mnt/host/media/usb',
rw: true,
},
],
blocks: [
{
name: 'sda',
type: 'disk',
fsType: '',
mount: '',
size: 120034123776,
physical: 'SSD',
uuid: '',
label: '',
model: 'K2',
serial: '',
removable: false,
protocol: 'sata',
group: '',
device: '/dev/sda',
},
{
name: 'sdb',
type: 'disk',
fsType: 'ext4',
mount: '/mnt/host/media/usb',
size: 1000204886016,
physical: 'HDD',
uuid: '34a8cfcd-35fd-4797-ac43-69c1f176762a',
label: '',
model: 'USB 3.0 Destop H',
serial: '',
removable: false,
protocol: 'usb',
group: '',
device: '/dev/sdb',
},
{
name: 'sda1',
type: 'part',
fsType: 'ext4',
mount: '/mnt/host',
size: 119009181696,
physical: '',
uuid: '3a3a6d61-726f-475f-a9b1-f028b3814021',
label: '',
model: '',
serial: '',
removable: false,
protocol: '',
group: '',
device: '/dev/sda',
},
{
name: 'sda2',
type: 'part',
fsType: '',
mount: '',
size: 1024,
physical: '',
uuid: '',
label: '',
model: '',
serial: '',
removable: false,
protocol: '',
group: '',
device: '/dev/sda',
},
{
name: 'sda5',
type: 'part',
fsType: 'swap',
mount: '[SWAP]',
size: 1022361600,
physical: '',
uuid: 'a96465f5-3925-456b-bd02-a3590c6c8179',
label: '',
model: '',
serial: '',
removable: false,
protocol: '',
group: '',
device: '/dev/sda',
},
{
name: 'sr0',
type: 'rom',
fsType: '',
mount: '',
size: 1073741312,
physical: 'CD/DVD',
uuid: '',
label: '',
model: 'DVD-RW DU8AESH',
serial: '',
removable: true,
protocol: 'usb',
group: '',
},
],
layout: [
{
disks: [{ brand: 'ATA', device: 'sda', type: 'SSD' }],
size: 120034123776,
},
{
disks: [{ brand: 'ASMT', device: 'sdb', type: 'HD' }],
size: 1000204886016,
},
],
output: [42625843200, 762590027776],
} as any as TestCase;
5 changes: 3 additions & 2 deletions apps/server/src/data/storage/dynamic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ export class DynamicStorageMapper {
// Setup local values
private getValidSizes() {
return this.sizes.filter(
({ mount, type }) =>
({ mount, type, rw }) =>
(this.hostWin32 || mount.startsWith(fromHost('/'))) &&
!CONFIG.fs_type_filter.includes(type)
!CONFIG.fs_type_filter.includes(type) &&
rw
);
}

Expand Down

0 comments on commit e031e35

Please sign in to comment.