Просмотр исходного кода

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.
James Allen 10 лет назад
Родитель
Сommit
b978171e0c
1 измененных файлов с 5 добавлено и 1 удалено
  1. 5 1
      services/web/app/coffee/Features/Project/ProjectLocator.coffee

+ 5 - 1
services/web/app/coffee/Features/Project/ProjectLocator.coffee

@@ -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