mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-30 00:15:23 -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"
|
smokeTest = require "smoke-test-sharelatex"
|
||||||
ContentTypeMapper = require "./app/js/ContentTypeMapper"
|
ContentTypeMapper = require "./app/js/ContentTypeMapper"
|
||||||
|
Errors = require './app/js/Errors'
|
||||||
|
|
||||||
Path = require "path"
|
Path = require "path"
|
||||||
fs = require "fs"
|
fs = require "fs"
|
||||||
|
@ -152,8 +153,12 @@ app.get "/heapdump", (req, res)->
|
||||||
res.send filename
|
res.send filename
|
||||||
|
|
||||||
app.use (error, req, res, next) ->
|
app.use (error, req, res, next) ->
|
||||||
logger.error err: error, "server error"
|
if error instanceof Errors.NotFoundError
|
||||||
res.sendStatus(error?.statusCode || 500)
|
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) ->
|
app.listen port = (Settings.internal?.clsi?.port or 3013), host = (Settings.internal?.clsi?.host or "localhost"), (error) ->
|
||||||
logger.info "CLSI starting up, listening on #{host}:#{port}"
|
logger.info "CLSI starting up, listening on #{host}:#{port}"
|
||||||
|
|
|
@ -13,6 +13,7 @@ fs = require("fs")
|
||||||
fse = require "fs-extra"
|
fse = require "fs-extra"
|
||||||
os = require("os")
|
os = require("os")
|
||||||
async = require "async"
|
async = require "async"
|
||||||
|
Errors = require './Errors'
|
||||||
|
|
||||||
commandRunner = Settings.clsi?.commandRunner or "./CommandRunner"
|
commandRunner = Settings.clsi?.commandRunner or "./CommandRunner"
|
||||||
logger.info commandRunner:commandRunner, "selecting command runner for clsi"
|
logger.info commandRunner:commandRunner, "selecting command runner for clsi"
|
||||||
|
@ -206,11 +207,11 @@ module.exports = CompileManager =
|
||||||
synctexFile = Path.join(synctexDir, "output.synctex.gz")
|
synctexFile = Path.join(synctexDir, "output.synctex.gz")
|
||||||
fs.stat synctexDir, (error, stats) ->
|
fs.stat synctexDir, (error, stats) ->
|
||||||
if error?.code is 'ENOENT'
|
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?
|
return callback(error) if error?
|
||||||
fs.stat synctexFile, (error, stats) ->
|
fs.stat synctexFile, (error, stats) ->
|
||||||
if error?.code is 'ENOENT'
|
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(error) if error?
|
||||||
return callback(new Error("not a file")) if not stats?.isFile()
|
return callback(new Error("not a file")) if not stats?.isFile()
|
||||||
callback()
|
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