From 7503739c22bac68540409355bad5bdcc27442f36 Mon Sep 17 00:00:00 2001 From: matlorr Date: Fri, 7 Feb 2025 09:43:35 +0100 Subject: [PATCH] Add line of contact for upload issues and set reserve disc space as environment variable. --- ecosystem.config.cjs | 2 ++ relay/import.mjs | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ecosystem.config.cjs b/ecosystem.config.cjs index e24dbd5..e0410d1 100644 --- a/ecosystem.config.cjs +++ b/ecosystem.config.cjs @@ -6,6 +6,8 @@ module.exports = { env: { LEAN4GAME_GITHUB_USER: "", LEAN4GAME_GITHUB_TOKEN: "", + RES_DISC_SPACE_PERCENTAGE: 1.0, + ISSUE_CONTACT: "", NODE_ENV: "production", PORT: 8002 }, diff --git a/relay/import.mjs b/relay/import.mjs index b1f384a..deaa98c 100644 --- a/relay/import.mjs +++ b/relay/import.mjs @@ -13,6 +13,8 @@ const __dirname = path.dirname(__filename); const TOKEN = process.env.LEAN4GAME_GITHUB_TOKEN const USERNAME = process.env.LEAN4GAME_GITHUB_USER +const MEM_THRESHOLD = process.env.RES_DISC_SPACE_PERCENTAGE +const CONTACT = process.env.ISSUE_CONTACT const octokit = new Octokit({ auth: TOKEN }) @@ -102,9 +104,11 @@ async function doImport (owner, repo, id) { const artifact = artifacts.data.artifacts .reduce((acc, cur) => acc.created_at < cur.created_at ? cur : acc) - await checkAgainstDiscMemory(artifact, 0.95); + await checkAgainstDiscMemory(artifact, MEM_THRESHOLD); + if (exceedingMemoryLimit === true) { - throw new Error(`Uploading file of size ${Math.round(artifact.size_in_bytes / 1024 / 1024)} (MB) would exceed allocated memory on the server.`); + throw new Error(`Uploading file of size ${Math.round(artifact.size_in_bytes / 1024 / 1024)} (MB) would exceed allocated memory on the server.\n + Please notify server admins via the LEAN zulip instance to resolve this issue.`); } artifactId = artifact.id