fix bug with unconverted resource types

This commit is contained in:
2025-10-07 21:36:36 +00:00
parent cc4caf9449
commit f2f4f45097
2 changed files with 5 additions and 5 deletions

View File

@@ -294,11 +294,11 @@ router.post(`${basePath}/create`, async (req, res) => {
// setup request
const request = {
cores: Number(params.cores),
memory: Number(params.memory)
memory: Number(params.memory) * 1024 ** 2
};
if (params.type === "lxc") {
request.swap = params.swap;
request[params.rootfslocation] = params.rootfssize;
request.swap = Number(params.swap) * 1024 ** 2;
request[params.rootfslocation] = params.rootfssize * 1024 ** 3;
}
for (const key of Object.keys(user.templates.instances[params.type])) {
const item = user.templates.instances[params.type][key];

View File

@@ -248,8 +248,8 @@ export async function approveResources (req, user, request, node) {
return false;
}
}
// if either the requested or avail resource is NaN, block
else if (isNaN(resourceData.avail) || isNaN(request[key])) {
// if either the requested or avail resource is not strictly a number, block
else if (typeof (resourceData.avail) !== "number" || typeof (request[key]) !== "number") {
approved = false;
return false;
}