Преглед изворни кода

Don't treat no root resource as a fatal error

James Allen пре 10 година
родитељ
комит
6beb29f449

+ 13 - 13
services/web/app/coffee/Features/Compile/ClsiManager.coffee

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

+ 4 - 4
services/web/test/UnitTests/coffee/Compile/ClsiManagerTests.coffee

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