Enhancement: Allow Disk Resources Widget For Combined Disk Mounts

This commit is contained in:
jeremyjohn 2024-06-01 01:46:37 +08:00
parent 1133891842
commit 0a090a065c

View File

@ -23,14 +23,14 @@ export default async function handler(req, res) {
} }
const fsSize = await si.fsSize(); const fsSize = await si.fsSize();
const rootTarget = fsSize.find((fs) => fs.mount === "/") || [];
let driveData; let driveData;
if (target === "/") { if (target === "/") {
const rootTarget = fsSize.find((fs) => fs.mount === "/"); driveData = [rootTarget];
driveData = rootTarget ?? [rootTarget];
} else { } else {
const foundTarget = fsSize.find((fs) => fs.mount === target); const filteredData = fsSize.filter((fs) => fs.mount.startsWith(target));
driveData = foundTarget ? [foundTarget] : fsSize; driveData = filteredData.length > 0 ? filteredData : [rootTarget];
} }
return res.status(200).json({ return res.status(200).json({