add disk usage task

This commit is contained in:
Girish Ramakrishnan
2022-10-12 10:26:21 +02:00
parent a3f7ce15ab
commit edb6ed91fe
7 changed files with 68 additions and 1 deletions

View File

@@ -10,6 +10,8 @@ exports = module.exports = {
isRebootRequired,
getConfig,
getDisks,
getDiskUsage,
updateDiskUsage,
getMemory,
getUpdateInfo,
update,
@@ -169,6 +171,20 @@ async function getDisks(req, res, next) {
next(new HttpSuccess(200, { disks: result }));
}
async function getDiskUsage(req, res, next) {
const [error, result] = await safe(system.getDiskUsage());
if (error) return next(BoxError.toHttpError(error));
next(new HttpSuccess(201, { usage: result }));
}
async function updateDiskUsage(req, res, next) {
const [error, taskId] = await safe(cloudron.updateDiskUsage());
if (error) return next(BoxError.toHttpError(error));
next(new HttpSuccess(201, { taskId }));
}
async function getMemory(req, res, next) {
const [error, result] = await safe(system.getMemory());
if (error) return next(BoxError.toHttpError(error));