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
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
path = path.replace(/^\//, "") # Remove leading /
@ -94,19 +97,16 @@ module.exports = ClsiManager =
url: "#{Settings.apis.filestore.url}/project/#{project._id}/file/#{file._id}"
modified: file.created?.getTime()
if !rootResourcePath?
callback new Error("no root document exists")
else
callback null, {
compile:
options:
compiler: project.compiler
timeout: options.timeout
imageName: project.imageName
draft: !!options.draft
rootResourcePath: rootResourcePath
resources: resources
}
callback null, {
compile:
options:
compiler: project.compiler
timeout: options.timeout
imageName: project.imageName
draft: !!options.draft
rootResourcePath: rootResourcePath
resources: resources
}
wordCount: (project_id, file, options, callback = (error, response) ->) ->
ClsiManager._buildRequest project_id, options, (error, req) ->

View file

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