mirror of
https://github.com/karl0ss/homepage.git
synced 2025-04-29 12:03:41 +01:00
fix fallback to / in disk resource widget
This commit is contained in:
parent
5677254b46
commit
c418efe007
@ -1,3 +1,5 @@
|
|||||||
|
import { existsSync } from "fs";
|
||||||
|
|
||||||
import { cpu, drive, mem } from "node-os-utils";
|
import { cpu, drive, mem } from "node-os-utils";
|
||||||
|
|
||||||
export default async function handler(req, res) {
|
export default async function handler(req, res) {
|
||||||
@ -13,6 +15,12 @@ export default async function handler(req, res) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (type === "disk") {
|
if (type === "disk") {
|
||||||
|
if (!existsSync(target)) {
|
||||||
|
return res.status(404).json({
|
||||||
|
error: "Target not found",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return res.status(200).json({
|
return res.status(200).json({
|
||||||
drive: await drive.info(target || "/"),
|
drive: await drive.info(target || "/"),
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user