fix update spawn error handling and reset flag

This commit is contained in:
Chris Wanstrath 2026-03-05 13:03:35 -08:00
parent 61c0c90695
commit d2339b8d44

View File

@ -304,9 +304,16 @@ router.get('/update', async c => {
router.post('/update', c => {
if (isUpdating) return c.json({ ok: false, error: 'update already in progress' }, 409)
isUpdating = true
try {
const script = join(projectRoot, 'install/install.sh')
Bun.spawn(['bash', script], { cwd: projectRoot, stdout: 'ignore', stderr: 'ignore' })
const proc = Bun.spawn(['bash', script], { cwd: projectRoot, stdout: 'ignore', stderr: 'ignore' })
proc.exited.then(code => { if (code !== 0) isUpdating = false })
.catch(() => { isUpdating = false })
return c.json({ ok: true })
} catch {
isUpdating = false
return c.json({ ok: false, error: 'failed to start update' }, 500)
}
})
export default router