Skip to content

Commit

Permalink
buildbot: 5/31 11:16
Browse files Browse the repository at this point in the history
  • Loading branch information
josephclaytonhansen committed May 31, 2024
1 parent 442e7c6 commit 7854312
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions backend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7854312

Please sign in to comment.