Add line of contact for upload issues and set reserve disc space as environment variable.

check_upload_size
matlorr 1 year ago
parent 836bd56e9a
commit 7503739c22

@ -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
},

@ -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 <a href=${CONTACT}>the LEAN zulip instance</a> to resolve this issue.`);
}
artifactId = artifact.id

Loading…
Cancel
Save