Merge pull request #4892 from overleaf/jk-token-zip-download-fix

Fix download-zip-from-v1 for users without overleaf ids

GitOrigin-RevId: cf70a010041e143b573d534eb956e4b48b108436
This commit is contained in:
June Kelly 2021-09-07 09:29:14 +01:00 committed by Copybot
parent e8b37b2e7d
commit cae921b30a

View file

@ -352,10 +352,31 @@ module.exports = HistoryController = {
}) })
return next(err) return next(err)
} }
if (response.statusCode !== 200) {
if (response.statusCode === 404) {
return next(new Errors.NotFoundError('zip not found'))
} else {
return next(
new OError('Error while getting zip for download', {
v1ProjectId,
statusCode: response.statusCode,
})
)
}
}
if (req.aborted) { if (req.aborted) {
// client has disconnected -- skip delayed s3 download // client has disconnected -- skip delayed s3 download
return return
} }
if (!body.zipUrl) {
return next(
new OError('Missing zipUrl, cannot fetch zip file', {
v1ProjectId,
body,
statusCode: response.statusCode,
})
)
}
let retryAttempt = 0 let retryAttempt = 0
let retryDelay = 2000 let retryDelay = 2000
// retry for about 6 minutes starting with short delay // retry for about 6 minutes starting with short delay