Merge branch 'deploy-20181029a'

GitOrigin-RevId: c51d4da706319564bd31514370fe13413655b6cf
This commit is contained in:
Douglas Lovell
2018-10-29 15:01:41 +00:00
committed by sharelatex
parent 207b0d84c7
commit b1bda995a6
10 changed files with 210 additions and 129 deletions
@@ -1,5 +1,6 @@
ProjectEntityHandler = require "./ProjectEntityHandler"
ProjectEntityUpdateHandler = require "./ProjectEntityUpdateHandler"
ProjectGetter = require "./ProjectGetter"
Path = require "path"
async = require("async")
_ = require("underscore")
@@ -45,13 +46,24 @@ module.exports = ProjectRootDocManager =
# docpaths have a leading / so allow matching "folder/filename" and "/folder/filename"
if path == rootDocName
root_doc_id = doc_id
# try a basename match if there was no match
# try a basename match if there was no match
if !root_doc_id
for doc_id, path of docPaths
if Path.basename(path) == Path.basename(rootDocName)
if Path.basename(path) == Path.basename(rootDocName)
root_doc_id = doc_id
# set the root doc id if we found a match
if root_doc_id?
ProjectEntityUpdateHandler.setRootDoc project_id, root_doc_id, callback
else
callback()
callback()
ensureRootDocumentIsSet: (project_id, callback = (error) ->) ->
ProjectGetter.getProject project_id, rootDoc_id: 1, (error, project) ->
return callback(error) if error?
if !project?
return callback new Error("project not found")
if project.rootDoc_id?
callback()
else
ProjectRootDocManager.setRootDocAutomatically project_id, callback