Skip to content

Commit

Permalink
fix(api): fallback to disk block info when no native disk found
Browse files Browse the repository at this point in the history
fixes #196
  • Loading branch information
MauriceNino committed Jul 10, 2022
1 parent 06d8b4f commit ca180c0
Showing 1 changed file with 26 additions and 24 deletions.
50 changes: 26 additions & 24 deletions apps/api/src/static-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,31 +128,33 @@ const loadStorageInfo = async (): Promise<void> => {
const diskRaidMem = raidMembers.filter(member =>
member.name.startsWith(device)
);
const nativeDisk = disks.find(d => d.name === disk.model);

if (nativeDisk != null) {
if (diskRaidMem.length > 0) {
const label = diskRaidMem[0].label.includes(':')
? diskRaidMem[0].label.split(':')[0]
: diskRaidMem[0].label;
return {
device: device,
brand: nativeDisk.vendor,
size: nativeDisk.size,
type: nativeDisk.type,
raidGroup: label,
};
} else {
return {
device: device,
brand: nativeDisk.vendor,
size: nativeDisk.size,
type: nativeDisk.type,
};
}
const nativeDisk = disks.find(
d => disk.model != '' && d.name === disk.model
) ?? {
vendor: disk.name,
size: disk.size,
type: disk.physical,
};

if (diskRaidMem.length > 0) {
const label = diskRaidMem[0].label.includes(':')
? diskRaidMem[0].label.split(':')[0]
: diskRaidMem[0].label;
return {
device: device,
brand: nativeDisk.vendor,
size: nativeDisk.size,
type: nativeDisk.type,
raidGroup: label,
};
} else {
return {
device: device,
brand: nativeDisk.vendor,
size: nativeDisk.size,
type: nativeDisk.type,
};
}

return undefined;
})
.filter(d => d != null);

Expand Down

0 comments on commit ca180c0

Please sign in to comment.