Don't treat no root resource as a fatal error

This commit is contained in:
James Allen 2016-03-21 13:28:53 +00:00
parent 8fb3e629e8
commit 6beb29f449
2 changed files with 17 additions and 17 deletions

View file

@ -86,6 +86,9 @@ module.exports = ClsiManager =
rootResourcePathOverride = path rootResourcePathOverride = path
rootResourcePath = rootResourcePathOverride if rootResourcePathOverride? rootResourcePath = rootResourcePathOverride if rootResourcePathOverride?
if !rootResourcePath?
logger.warn {project_id}, "no root document found, setting to main.tex"
rootResourcePath = "main.tex"
for path, file of files for path, file of files
path = path.replace(/^\//, "") # Remove leading / path = path.replace(/^\//, "") # Remove leading /
@ -94,19 +97,16 @@ module.exports = ClsiManager =
url: "#{Settings.apis.filestore.url}/project/#{project._id}/file/#{file._id}" url: "#{Settings.apis.filestore.url}/project/#{project._id}/file/#{file._id}"
modified: file.created?.getTime() modified: file.created?.getTime()
if !rootResourcePath? callback null, {
callback new Error("no root document exists") compile:
else options:
callback null, { compiler: project.compiler
compile: timeout: options.timeout
options: imageName: project.imageName
compiler: project.compiler draft: !!options.draft
timeout: options.timeout rootResourcePath: rootResourcePath
imageName: project.imageName resources: resources
draft: !!options.draft }
rootResourcePath: rootResourcePath
resources: resources
}
wordCount: (project_id, file, options, callback = (error, response) ->) -> wordCount: (project_id, file, options, callback = (error, response) ->) ->
ClsiManager._buildRequest project_id, options, (error, req) -> ClsiManager._buildRequest project_id, options, (error, req) ->

View file

@ -19,7 +19,7 @@ describe "ClsiManager", ->
url: "https://clsipremium.example.com" url: "https://clsipremium.example.com"
"../../models/Project": Project: @Project = {} "../../models/Project": Project: @Project = {}
"../Project/ProjectEntityHandler": @ProjectEntityHandler = {} "../Project/ProjectEntityHandler": @ProjectEntityHandler = {}
"logger-sharelatex": @logger = { log: sinon.stub(), error: sinon.stub() } "logger-sharelatex": @logger = { log: sinon.stub(), error: sinon.stub(), warn: sinon.stub() }
"request": @request = {} "request": @request = {}
@project_id = "project-id" @project_id = "project-id"
@callback = sinon.stub() @callback = sinon.stub()
@ -218,9 +218,9 @@ describe "ClsiManager", ->
@project.rootDoc_id = "not-valid" @project.rootDoc_id = "not-valid"
@ClsiManager._buildRequest @project, null, (@error, @request) => @ClsiManager._buildRequest @project, null, (@error, @request) =>
done() done()
it "should return an error", -> it "should set to main.tex", ->
expect(@error).to.exist @request.compile.rootResourcePath.should.equal "main.tex"
describe "with the draft option", -> describe "with the draft option", ->
it "should add the draft option into the request", (done) -> it "should add the draft option into the request", (done) ->