mirror of
https://github.com/overleaf/overleaf.git
synced 2024-09-16 02:52:31 -04:00
Revert "Revert "Revert "decaf clean up"""
This reverts commit 4a3933668a0d01912e748c164581bcb9bbded0dd. GitOrigin-RevId: 829a5c65093200db066f5852e42bd4f88d4c299a
This commit is contained in:
parent
ba253bee12
commit
353625be51
1 changed files with 40 additions and 20 deletions
|
@ -10,6 +10,7 @@
|
||||||
/*
|
/*
|
||||||
* decaffeinate suggestions:
|
* decaffeinate suggestions:
|
||||||
* DS102: Remove unnecessary code created because of implicit returns
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
* DS103: Rewrite code to no longer use __guard__
|
||||||
* DS207: Consider shorter variations of null checks
|
* DS207: Consider shorter variations of null checks
|
||||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||||
*/
|
*/
|
||||||
|
@ -34,47 +35,59 @@ const COMPILE_TIMEOUT_MS = 10 * 60 * 1000
|
||||||
|
|
||||||
module.exports = CompileController = {
|
module.exports = CompileController = {
|
||||||
compile(req, res, next) {
|
compile(req, res, next) {
|
||||||
|
if (next == null) {
|
||||||
|
next = function(error) {}
|
||||||
|
}
|
||||||
res.setTimeout(COMPILE_TIMEOUT_MS)
|
res.setTimeout(COMPILE_TIMEOUT_MS)
|
||||||
const project_id = req.params.Project_id
|
const project_id = req.params.Project_id
|
||||||
const isAutoCompile = !!req.query.auto_compile
|
const isAutoCompile = !!(req.query != null
|
||||||
|
? req.query.auto_compile
|
||||||
|
: undefined)
|
||||||
const user_id = AuthenticationController.getLoggedInUserId(req)
|
const user_id = AuthenticationController.getLoggedInUserId(req)
|
||||||
const options = {
|
const options = {
|
||||||
isAutoCompile
|
isAutoCompile
|
||||||
}
|
}
|
||||||
|
if ((req.body != null ? req.body.rootDoc_id : undefined) != null) {
|
||||||
if (req.body.rootDoc_id) {
|
|
||||||
options.rootDoc_id = req.body.rootDoc_id
|
options.rootDoc_id = req.body.rootDoc_id
|
||||||
} else if (req.body.settingsOverride && req.body.settingsOverride.rootDoc_id) {
|
} else if (
|
||||||
|
__guard__(
|
||||||
|
req.body != null ? req.body.settingsOverride : undefined,
|
||||||
|
x => x.rootDoc_id
|
||||||
|
) != null
|
||||||
|
) {
|
||||||
// Can be removed after deploy
|
// Can be removed after deploy
|
||||||
options.rootDoc_id = req.body.settingsOverride.rootDoc_id
|
options.rootDoc_id = req.body.settingsOverride.rootDoc_id
|
||||||
}
|
}
|
||||||
if (req.body.compiler) {
|
if (req.body != null ? req.body.compiler : undefined) {
|
||||||
options.compiler = req.body.compiler
|
options.compiler = req.body.compiler
|
||||||
}
|
}
|
||||||
if (req.body.draft) {
|
if (req.body != null ? req.body.draft : undefined) {
|
||||||
options.draft = req.body.draft
|
options.draft = req.body.draft
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
['validate', 'error', 'silent'].includes(req.body.check)
|
['validate', 'error', 'silent'].includes(
|
||||||
|
req.body != null ? req.body.check : undefined
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
options.check = req.body.check
|
options.check = req.body.check
|
||||||
}
|
}
|
||||||
if (req.body.incrementalCompilesEnabled) {
|
if (req.body != null ? req.body.incrementalCompilesEnabled : undefined) {
|
||||||
options.incrementalCompilesEnabled = true
|
options.incrementalCompilesEnabled = true
|
||||||
}
|
}
|
||||||
|
return CompileManager.compile(project_id, user_id, options, function(
|
||||||
CompileManager.compile(project_id, user_id, options, (
|
|
||||||
error,
|
error,
|
||||||
status,
|
status,
|
||||||
outputFiles,
|
outputFiles,
|
||||||
clsiServerId,
|
clsiServerId,
|
||||||
limits,
|
limits,
|
||||||
validationProblems
|
validationProblems
|
||||||
) => {
|
) {
|
||||||
if (error) {
|
if (error != null) {
|
||||||
return next(error)
|
return next(error)
|
||||||
}
|
}
|
||||||
res.json({
|
res.contentType('application/json')
|
||||||
|
return res.status(200).send(
|
||||||
|
JSON.stringify({
|
||||||
status,
|
status,
|
||||||
outputFiles,
|
outputFiles,
|
||||||
compileGroup: limits != null ? limits.compileGroup : undefined,
|
compileGroup: limits != null ? limits.compileGroup : undefined,
|
||||||
|
@ -82,6 +95,7 @@ module.exports = CompileController = {
|
||||||
validationProblems,
|
validationProblems,
|
||||||
pdfDownloadDomain: Settings.pdfDownloadDomain
|
pdfDownloadDomain: Settings.pdfDownloadDomain
|
||||||
})
|
})
|
||||||
|
)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -526,3 +540,9 @@ module.exports = CompileController = {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function __guard__(value, transform) {
|
||||||
|
return typeof value !== 'undefined' && value !== null
|
||||||
|
? transform(value)
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue