mirror of
https://github.com/unraid/api.git
synced 2026-01-01 06:01:18 -06:00
fix: use batchProcess
This commit is contained in:
@@ -5,6 +5,7 @@ import { blockDevices, diskLayout } from 'systeminformation';
|
|||||||
import type { Disk } from '@app/graphql/generated/api/types';
|
import type { Disk } from '@app/graphql/generated/api/types';
|
||||||
import { graphqlLogger } from '@app/core/log';
|
import { graphqlLogger } from '@app/core/log';
|
||||||
import { DiskFsType, DiskInterfaceType, DiskSmartStatus } from '@app/graphql/generated/api/types';
|
import { DiskFsType, DiskInterfaceType, DiskSmartStatus } from '@app/graphql/generated/api/types';
|
||||||
|
import { batchProcess } from '@app/utils';
|
||||||
|
|
||||||
const getTemperature = async (disk: Systeminformation.DiskLayoutData): Promise<number> => {
|
const getTemperature = async (disk: Systeminformation.DiskLayoutData): Promise<number> => {
|
||||||
try {
|
try {
|
||||||
@@ -82,9 +83,9 @@ export const getDisks = async (options?: { temperature: boolean }): Promise<Disk
|
|||||||
const partitions = await blockDevices().then((devices) =>
|
const partitions = await blockDevices().then((devices) =>
|
||||||
devices.filter((device) => device.type === 'part')
|
devices.filter((device) => device.type === 'part')
|
||||||
);
|
);
|
||||||
const disks = await Promise.all(
|
|
||||||
(await diskLayout()).map((disk) => parseDisk(disk, partitions, true))
|
|
||||||
);
|
|
||||||
|
|
||||||
return disks;
|
const { data } = await batchProcess(await diskLayout(), async (disk) =>
|
||||||
|
parseDisk(disk, partitions, true)
|
||||||
|
);
|
||||||
|
return data;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user