Merge pull request #3495 from overleaf/ae-prettier-2

Upgrade Prettier to v2

GitOrigin-RevId: 85aa3fa1acb6332c4f58c46165a43d1a51471f33
This commit is contained in:
Alf Eaton
2021-04-15 02:05:22 +00:00
committed by Copybot
parent 930d7ba028
commit 1ebc8a79cb
582 changed files with 20382 additions and 20374 deletions
@@ -104,11 +104,11 @@ module.exports = CompileController = {
stopCompile(req, res, next) {
if (next == null) {
next = function(error) {}
next = function (error) {}
}
const project_id = req.params.Project_id
const user_id = AuthenticationController.getLoggedInUserId(req)
return CompileManager.stopCompile(project_id, user_id, function(error) {
return CompileManager.stopCompile(project_id, user_id, function (error) {
if (error != null) {
return next(error)
}
@@ -119,7 +119,7 @@ module.exports = CompileController = {
// Used for submissions through the public API
compileSubmission(req, res, next) {
if (next == null) {
next = function(error) {}
next = function (error) {}
}
res.setTimeout(COMPILE_TIMEOUT_MS)
const { submission_id } = req.params
@@ -150,7 +150,7 @@ module.exports = CompileController = {
submission_id,
req.body,
options,
function(error, status, outputFiles, clsiServerId, validationProblems) {
function (error, status, outputFiles, clsiServerId, validationProblems) {
if (error != null) {
return next(error)
}
@@ -189,13 +189,13 @@ module.exports = CompileController = {
downloadPdf(req, res, next) {
if (next == null) {
next = function(error) {}
next = function (error) {}
}
Metrics.inc('pdf-downloads')
const project_id = req.params.Project_id
const isPdfjsPartialDownload =
req.query != null ? req.query.pdfng : undefined
const rateLimit = function(callback) {
const rateLimit = function (callback) {
if (isPdfjsPartialDownload) {
return callback(null, true)
} else {
@@ -209,51 +209,52 @@ module.exports = CompileController = {
}
}
return ProjectGetter.getProject(project_id, { name: 1 }, function(
err,
project
) {
res.contentType('application/pdf')
const filename = `${CompileController._getSafeProjectName(project)}.pdf`
return ProjectGetter.getProject(
project_id,
{ name: 1 },
function (err, project) {
res.contentType('application/pdf')
const filename = `${CompileController._getSafeProjectName(project)}.pdf`
if (req.query.popupDownload) {
res.setContentDisposition('attachment', { filename })
} else {
res.setContentDisposition('', { filename })
}
return rateLimit(function(err, canContinue) {
if (err != null) {
logger.err({ err }, 'error checking rate limit for pdf download')
return res.sendStatus(500)
} else if (!canContinue) {
logger.log(
{ project_id, ip: req.ip },
'rate limit hit downloading pdf'
)
return res.sendStatus(500)
if (req.query.popupDownload) {
res.setContentDisposition('attachment', { filename })
} else {
return CompileController._downloadAsUser(req, function(
error,
user_id
) {
const url = CompileController._getFileUrl(
project_id,
user_id,
req.params.build_id,
'output.pdf'
)
return CompileController.proxyToClsi(
project_id,
url,
req,
res,
next
)
})
res.setContentDisposition('', { filename })
}
})
})
return rateLimit(function (err, canContinue) {
if (err != null) {
logger.err({ err }, 'error checking rate limit for pdf download')
return res.sendStatus(500)
} else if (!canContinue) {
logger.log(
{ project_id, ip: req.ip },
'rate limit hit downloading pdf'
)
return res.sendStatus(500)
} else {
return CompileController._downloadAsUser(
req,
function (error, user_id) {
const url = CompileController._getFileUrl(
project_id,
user_id,
req.params.build_id,
'output.pdf'
)
return CompileController.proxyToClsi(
project_id,
url,
req,
res,
next
)
}
)
}
})
}
)
},
_getSafeProjectName(project) {
@@ -264,18 +265,21 @@ module.exports = CompileController = {
deleteAuxFiles(req, res, next) {
const project_id = req.params.Project_id
const { clsiserverid } = req.query
return CompileController._compileAsUser(req, function(error, user_id) {
return CompileController._compileAsUser(req, function (error, user_id) {
if (error != null) {
return next(error)
}
CompileManager.deleteAuxFiles(project_id, user_id, clsiserverid, function(
error
) {
if (error != null) {
return next(error)
CompileManager.deleteAuxFiles(
project_id,
user_id,
clsiserverid,
function (error) {
if (error != null) {
return next(error)
}
return res.sendStatus(200)
}
return res.sendStatus(200)
})
)
})
},
@@ -283,7 +287,7 @@ module.exports = CompileController = {
compileAndDownloadPdf(req, res, next) {
const { project_id } = req.params
// pass user_id as null, since templates are an "anonymous" compile
return CompileManager.compile(project_id, null, {}, function(err) {
return CompileManager.compile(project_id, null, {}, function (err) {
if (err != null) {
logger.err(
{ err, project_id },
@@ -298,10 +302,10 @@ module.exports = CompileController = {
getFileFromClsi(req, res, next) {
if (next == null) {
next = function(error) {}
next = function (error) {}
}
const project_id = req.params.Project_id
return CompileController._downloadAsUser(req, function(error, user_id) {
return CompileController._downloadAsUser(req, function (error, user_id) {
if (error != null) {
return next(error)
}
@@ -317,7 +321,7 @@ module.exports = CompileController = {
getFileFromClsiWithoutUser(req, res, next) {
if (next == null) {
next = function(error) {}
next = function (error) {}
}
const { submission_id } = req.params
const url = CompileController._getFileUrl(
@@ -367,7 +371,7 @@ module.exports = CompileController = {
proxySyncPdf(req, res, next) {
if (next == null) {
next = function(error) {}
next = function (error) {}
}
const project_id = req.params.Project_id
const { page, h, v } = req.query
@@ -381,7 +385,7 @@ module.exports = CompileController = {
return next(new Error('invalid v parameter'))
}
// whether this request is going to a per-user container
return CompileController._compileAsUser(req, function(error, user_id) {
return CompileController._compileAsUser(req, function (error, user_id) {
if (error != null) {
return next(error)
}
@@ -403,7 +407,7 @@ module.exports = CompileController = {
proxySyncCode(req, res, next) {
if (next == null) {
next = function(error) {}
next = function (error) {}
}
const project_id = req.params.Project_id
const { file, line, column } = req.query
@@ -425,7 +429,7 @@ module.exports = CompileController = {
if (!(column != null ? column.match(/^\d+$/) : undefined)) {
return next(new Error('invalid column parameter'))
}
return CompileController._compileAsUser(req, function(error, user_id) {
return CompileController._compileAsUser(req, function (error, user_id) {
if (error != null) {
return next(error)
}
@@ -447,7 +451,7 @@ module.exports = CompileController = {
proxyToClsi(project_id, url, req, res, next) {
if (next == null) {
next = function(error) {}
next = function (error) {}
}
if (req.query != null ? req.query.compileGroup : undefined) {
return CompileController.proxyToClsiWithLimits(
@@ -459,28 +463,28 @@ module.exports = CompileController = {
next
)
} else {
return CompileManager.getProjectCompileLimits(project_id, function(
error,
limits
) {
if (error != null) {
return next(error)
return CompileManager.getProjectCompileLimits(
project_id,
function (error, limits) {
if (error != null) {
return next(error)
}
return CompileController.proxyToClsiWithLimits(
project_id,
url,
limits,
req,
res,
next
)
}
return CompileController.proxyToClsiWithLimits(
project_id,
url,
limits,
req,
res,
next
)
})
)
}
},
proxyToClsiWithLimits(project_id, url, limits, req, res, next) {
if (next == null) {
next = function(error) {}
next = function (error) {}
}
_getPersistenceOptions(req, project_id, (err, persistenceOptions) => {
let qs
@@ -541,7 +545,7 @@ module.exports = CompileController = {
const project_id = req.params.Project_id
const file = req.query.file || false
const { clsiserverid } = req.query
return CompileController._compileAsUser(req, function(error, user_id) {
return CompileController._compileAsUser(req, function (error, user_id) {
if (error != null) {
return next(error)
}
@@ -550,7 +554,7 @@ module.exports = CompileController = {
user_id,
file,
clsiserverid,
function(error, body) {
function (error, body) {
if (error != null) {
return next(error)
}