mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #14408 from overleaf/jpa-server-pro-history-zip-name
[web] fix file name for history zip download in Server Pro/CE GitOrigin-RevId: e51213c4758bf241f8291a67231169ad7d54d423
This commit is contained in:
parent
ebebcf5956
commit
ec11a74452
1 changed files with 27 additions and 6 deletions
|
@ -317,14 +317,35 @@ module.exports = HistoryController = {
|
||||||
if (!Features.hasFeature('saas')) {
|
if (!Features.hasFeature('saas')) {
|
||||||
const getReq = request({ ...options, method: 'get' })
|
const getReq = request({ ...options, method: 'get' })
|
||||||
|
|
||||||
pipeline(getReq, res, function (err) {
|
getReq.on('error', function (err) {
|
||||||
|
logger.warn({ err, v1ProjectId, version }, 'history zip download error')
|
||||||
|
res.sendStatus(500)
|
||||||
|
})
|
||||||
|
getReq.on('response', function (response) {
|
||||||
|
const statusCode = response.statusCode
|
||||||
|
if (statusCode !== 200) {
|
||||||
|
logger.warn(
|
||||||
|
{ v1ProjectId, version, statusCode },
|
||||||
|
'history zip download failed'
|
||||||
|
)
|
||||||
|
if (statusCode === 404) {
|
||||||
|
res.sendStatus(404)
|
||||||
|
} else {
|
||||||
|
res.sendStatus(500)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
prepareZipAttachment(res, `${name}.zip`)
|
||||||
|
pipeline(response, res, function (err) {
|
||||||
// If the downstream request is cancelled, we get an
|
// If the downstream request is cancelled, we get an
|
||||||
// ERR_STREAM_PREMATURE_CLOSE.
|
// ERR_STREAM_PREMATURE_CLOSE.
|
||||||
if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') {
|
if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') {
|
||||||
logger.error({ url, err }, 'history API error')
|
logger.error({ err, v1ProjectId, version }, 'history API error')
|
||||||
next(err)
|
next(err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue