Преглед на файлове

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 години
родител
ревизия
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