only check capture if not page is not cached

This commit is contained in:
keyan 2022-01-12 19:35:17 -06:00
parent 3d94ef32ac
commit f9016d13ee
1 changed files with 6 additions and 6 deletions

View File

@ -15,12 +15,6 @@ AWS.config.update({
}) })
export default async function handler (req, res) { export default async function handler (req, res) {
if (capturing) {
return res.writeHead(503, {
'Retry-After' : 1
}).end()
}
return new Promise(resolve => { return new Promise(resolve => {
const joinedPath = path.join(...(req.query.path || [])) const joinedPath = path.join(...(req.query.path || []))
const s3Path = s3PathPrefix + (joinedPath === '.' ? '_' : joinedPath) const s3Path = s3PathPrefix + (joinedPath === '.' ? '_' : joinedPath)
@ -38,6 +32,12 @@ export default async function handler (req, res) {
resolve() resolve()
}).catch(() => { }).catch(() => {
// we don't have it cached, so capture it and cache it // we don't have it cached, so capture it and cache it
if (capturing) {
return res.writeHead(503, {
'Retry-After' : 1
}).end()
}
capturing = true capturing = true
const pass = new PassThrough() const pass = new PassThrough()
aws.upload({ aws.upload({