Skip to content

Commit 2b91838

Browse files
committed
fix: very inefficient reducer
1 parent d3be153 commit 2b91838

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

api/src/unraid-api/graph/resolvers/display/display.service.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,10 @@ export class DisplayService {
111111

112112
const state = filePaths.reduce<Partial<DynamixConfig>>((acc, filePath) => {
113113
const state = loadState<DynamixConfig>(filePath);
114-
return state ? { ...acc, ...state } : acc;
114+
if (state) {
115+
Object.assign(acc, state);
116+
}
117+
return acc;
115118
}, {});
116119

117120
if (!state.display) {

api/src/unraid-api/graph/resolvers/info/devices.service.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Injectable } from '@nestjs/common';
1+
import { Injectable, Logger } from '@nestjs/common';
22
import { randomUUID } from 'crypto';
33
import { access } from 'fs/promises';
44

@@ -22,6 +22,8 @@ import {
2222

2323
@Injectable()
2424
export class DevicesService {
25+
private readonly logger = new Logger(DevicesService.name);
26+
2527
async generateGpu(): Promise<Gpu[]> {
2628
try {
2729
const systemPciDevices = await this.getSystemPciDevices();
@@ -39,7 +41,11 @@ export class DevicesService {
3941
};
4042
return gpu;
4143
});
42-
} catch {
44+
} catch (error: unknown) {
45+
this.logger.error(
46+
`Failed to generate GPU devices: ${error instanceof Error ? error.message : String(error)}`,
47+
error instanceof Error ? error.stack : undefined
48+
);
4349
return [];
4450
}
4551
}
@@ -58,7 +64,11 @@ export class DevicesService {
5864
blacklisted: device.allowed ? 'true' : 'false',
5965
class: device.class,
6066
}));
61-
} catch {
67+
} catch (error: unknown) {
68+
this.logger.error(
69+
`Failed to generate PCI devices: ${error instanceof Error ? error.message : String(error)}`,
70+
error instanceof Error ? error.stack : undefined
71+
);
6272
return [];
6373
}
6474
}
@@ -70,7 +80,11 @@ export class DevicesService {
7080
id: `usb/${device.id}`,
7181
name: device.name,
7282
}));
73-
} catch {
83+
} catch (error: unknown) {
84+
this.logger.error(
85+
`Failed to generate USB devices: ${error instanceof Error ? error.message : String(error)}`,
86+
error instanceof Error ? error.stack : undefined
87+
);
7488
return [];
7589
}
7690
}

0 commit comments

Comments
 (0)