Fix "cannot set headers after sent" in setting doc end point

If somehow a project ends up with the same doc/file in two locations in the
file tree, then projectLocator.findElement will return the callback for
both entries. This then tries to end the request multiple times. Of course
this should never be a state the project is in, but if it is we should catch it.
This commit is contained in:
James Allen 2016-02-05 15:39:26 +00:00
parent 835b43cab2
commit b978171e0c

View file

@ -5,7 +5,11 @@ logger = require('logger-sharelatex')
async = require('async')
module.exports =
findElement: (options, callback = (err, element, path, parentFolder)->)->
findElement: (options, _callback = (err, element, path, parentFolder)->)->
callback = (args...) ->
_callback(args...)
_callback = () ->
{project, project_id, element_id, type} = options
elementType = sanitizeTypeOfElement type