From 7854312d119266d8bc3553c8fcaeb351d344359a Mon Sep 17 00:00:00 2001 From: Joseph Hansen <45859835+josephclaytonhansen@users.noreply.github.com> Date: Fri, 31 May 2024 11:16:04 -0500 Subject: [PATCH] buildbot: 5/31 11:16 --- backend/index.js | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/backend/index.js b/backend/index.js index 30b14d6e..d871ddd7 100644 --- a/backend/index.js +++ b/backend/index.js @@ -99,24 +99,16 @@ import startBuildProcess from './workers/startBuildProcess.js' let jobs = {} -let jobId = 0 -const jobIdFilePath = path.join(dir, '.jobid') - -try { - if (fs.existsSync(jobIdFilePath)) { - jobId = Number(fs.readFileSync(jobIdFilePath, 'utf8')) - } else { - fs.writeFileSync(jobIdFilePath, '0') - } -} catch (err) { - console.error('Failed to load or create jobId file:', err) +const randomFiveDigitNumber = () => { + return Math.floor(10000 + Math.random() * 90000) } +let jobId = 0 app.post('/build', [buildLimiter, authenticateToken], async (req, res) => { if (!req.isAuthenticated() || req.user.role !== 'admin') { return res.status(403).send('Not authorized') } - jobId++ + let jobId = randomFiveDigitNumber() fs.writeFile(path.join(dir, '.jobid'), String(jobId), (err) => { if (err) { console.error('Failed to save jobId to file:', err)