mirror of
https://github.com/github/codeql-action
synced 2026-05-29 05:00:55 +03:00
Handle files that exist but whose contents are not integers
This commit is contained in:
Generated
+11
-7
@@ -154,13 +154,17 @@ exports.getMemoryFlagValueForPlatform = getMemoryFlagValueForPlatform;
|
||||
*/
|
||||
function getTotalMemoryAvailable() {
|
||||
if (os.platform() === "linux") {
|
||||
// Respect constraints imposed by Linux cgroups v1
|
||||
if (fs.existsSync("/sys/fs/cgroup/memory/memory.limit_in_bytes")) {
|
||||
return Number(fs.readFileSync("/sys/fs/cgroup/memory/memory.limit_in_bytes", "utf8"));
|
||||
}
|
||||
// Respect constraints imposed by Linux cgroups v2
|
||||
if (fs.existsSync("/sys/fs/cgroup/memory.max")) {
|
||||
return Number(fs.readFileSync("/sys/fs/cgroup/memory.max", "utf8"));
|
||||
// Respect constraints imposed by Linux cgroups v1 and v2
|
||||
for (const limitFile of [
|
||||
"/sys/fs/cgroup/memory/memory.limit_in_bytes",
|
||||
"/sys/fs/cgroup/memory.max",
|
||||
]) {
|
||||
if (fs.existsSync(limitFile)) {
|
||||
const limit = Number(fs.readFileSync(limitFile, "utf8"));
|
||||
if (Number.isInteger(limit)) {
|
||||
return limit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return os.totalmem();
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+11
-9
@@ -217,15 +217,17 @@ export function getMemoryFlagValueForPlatform(
|
||||
*/
|
||||
function getTotalMemoryAvailable(): number {
|
||||
if (os.platform() === "linux") {
|
||||
// Respect constraints imposed by Linux cgroups v1
|
||||
if (fs.existsSync("/sys/fs/cgroup/memory/memory.limit_in_bytes")) {
|
||||
return Number(
|
||||
fs.readFileSync("/sys/fs/cgroup/memory/memory.limit_in_bytes", "utf8"),
|
||||
);
|
||||
}
|
||||
// Respect constraints imposed by Linux cgroups v2
|
||||
if (fs.existsSync("/sys/fs/cgroup/memory.max")) {
|
||||
return Number(fs.readFileSync("/sys/fs/cgroup/memory.max", "utf8"));
|
||||
// Respect constraints imposed by Linux cgroups v1 and v2
|
||||
for (const limitFile of [
|
||||
"/sys/fs/cgroup/memory/memory.limit_in_bytes",
|
||||
"/sys/fs/cgroup/memory.max",
|
||||
]) {
|
||||
if (fs.existsSync(limitFile)) {
|
||||
const limit = Number(fs.readFileSync(limitFile, "utf8"));
|
||||
if (Number.isInteger(limit)) {
|
||||
return limit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return os.totalmem();
|
||||
|
||||
Reference in New Issue
Block a user