mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
[web] pipe history zip download to history-v1 in CE/SP (#11362)
GitOrigin-RevId: 4ef181d1b79b3d0e2254af698defe0c2fa8c679f
This commit is contained in:
parent
2291fd5dae
commit
b4e9bf3449
2 changed files with 17 additions and 2 deletions
|
@ -13,6 +13,7 @@ const ProjectEntityUpdateHandler = require('../Project/ProjectEntityUpdateHandle
|
||||||
const RestoreManager = require('./RestoreManager')
|
const RestoreManager = require('./RestoreManager')
|
||||||
const { pipeline } = require('stream')
|
const { pipeline } = require('stream')
|
||||||
const { prepareZipAttachment } = require('../../infrastructure/Response')
|
const { prepareZipAttachment } = require('../../infrastructure/Response')
|
||||||
|
const Features = require('../../infrastructure/Features')
|
||||||
|
|
||||||
module.exports = HistoryController = {
|
module.exports = HistoryController = {
|
||||||
selectHistoryApi(req, res, next) {
|
selectHistoryApi(req, res, next) {
|
||||||
|
@ -344,10 +345,20 @@ module.exports = HistoryController = {
|
||||||
pass: settings.apis.v1_history.pass,
|
pass: settings.apis.v1_history.pass,
|
||||||
},
|
},
|
||||||
json: true,
|
json: true,
|
||||||
method: 'post',
|
|
||||||
url,
|
url,
|
||||||
}
|
}
|
||||||
request(options, function (err, response, body) {
|
|
||||||
|
if (!Features.hasFeature('saas')) {
|
||||||
|
const getReq = request({ ...options, method: 'get' })
|
||||||
|
getReq.pipe(res)
|
||||||
|
getReq.on('error', function (err) {
|
||||||
|
logger.error({ url, err }, 'history API error')
|
||||||
|
next(err)
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
request({ ...options, method: 'post' }, function (err, response, body) {
|
||||||
if (err) {
|
if (err) {
|
||||||
OError.tag(err, 'history API error', {
|
OError.tag(err, 'history API error', {
|
||||||
v1ProjectId,
|
v1ProjectId,
|
||||||
|
|
|
@ -34,6 +34,10 @@ describe('HistoryController', function () {
|
||||||
(this.ProjectEntityUpdateHandler = {}),
|
(this.ProjectEntityUpdateHandler = {}),
|
||||||
'../User/UserGetter': (this.UserGetter = {}),
|
'../User/UserGetter': (this.UserGetter = {}),
|
||||||
'./RestoreManager': (this.RestoreManager = {}),
|
'./RestoreManager': (this.RestoreManager = {}),
|
||||||
|
'../../infrastructure/Features': (this.Features = sinon
|
||||||
|
.stub()
|
||||||
|
.withArgs('saas')
|
||||||
|
.returns(true)),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
return (this.settings.apis = {
|
return (this.settings.apis = {
|
||||||
|
|
Loading…
Reference in a new issue