mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Send a 404 if the project files have gone away when running synctex.
This is semantically nicer than the 500 response which used to be produced in these circumstances.
This commit is contained in:
parent
65eaf0ad10
commit
a55debb79f
3 changed files with 20 additions and 4 deletions
|
@ -7,6 +7,7 @@ if Settings.sentry?.dsn?
|
|||
|
||||
smokeTest = require "smoke-test-sharelatex"
|
||||
ContentTypeMapper = require "./app/js/ContentTypeMapper"
|
||||
Errors = require './app/js/Errors'
|
||||
|
||||
Path = require "path"
|
||||
fs = require "fs"
|
||||
|
@ -152,7 +153,11 @@ app.get "/heapdump", (req, res)->
|
|||
res.send filename
|
||||
|
||||
app.use (error, req, res, next) ->
|
||||
logger.error err: error, "server error"
|
||||
if error instanceof Errors.NotFoundError
|
||||
logger.warn {err: error, url: req.url}, "not found error"
|
||||
return res.sendStatus(404)
|
||||
else
|
||||
logger.error {err: error, url: req.url}, "server error"
|
||||
res.sendStatus(error?.statusCode || 500)
|
||||
|
||||
app.listen port = (Settings.internal?.clsi?.port or 3013), host = (Settings.internal?.clsi?.host or "localhost"), (error) ->
|
||||
|
|
|
@ -13,6 +13,7 @@ fs = require("fs")
|
|||
fse = require "fs-extra"
|
||||
os = require("os")
|
||||
async = require "async"
|
||||
Errors = require './Errors'
|
||||
|
||||
commandRunner = Settings.clsi?.commandRunner or "./CommandRunner"
|
||||
logger.info commandRunner:commandRunner, "selecting command runner for clsi"
|
||||
|
@ -206,11 +207,11 @@ module.exports = CompileManager =
|
|||
synctexFile = Path.join(synctexDir, "output.synctex.gz")
|
||||
fs.stat synctexDir, (error, stats) ->
|
||||
if error?.code is 'ENOENT'
|
||||
return callback(new Error("called synctex with no output directory"))
|
||||
return callback(new Errors.NotFoundError("called synctex with no output directory"))
|
||||
return callback(error) if error?
|
||||
fs.stat synctexFile, (error, stats) ->
|
||||
if error?.code is 'ENOENT'
|
||||
return callback(new Error("called synctex with no output file"))
|
||||
return callback(new Errors.NotFoundError("called synctex with no output file"))
|
||||
return callback(error) if error?
|
||||
return callback(new Error("not a file")) if not stats?.isFile()
|
||||
callback()
|
||||
|
|
10
services/clsi/app/coffee/Errors.coffee
Normal file
10
services/clsi/app/coffee/Errors.coffee
Normal file
|
@ -0,0 +1,10 @@
|
|||
NotFoundError = (message) ->
|
||||
error = new Error(message)
|
||||
error.name = "NotFoundError"
|
||||
error.__proto__ = NotFoundError.prototype
|
||||
return error
|
||||
NotFoundError.prototype.__proto__ = Error.prototype
|
||||
|
||||
|
||||
module.exports = Errors =
|
||||
NotFoundError: NotFoundError
|
Loading…
Reference in a new issue