Просмотр исходного кода

Only auto clear CLSI cache on hard error, otherwise prompt user

James Allen 12 лет назад
Родитель
Сommit
063f6c7680

+ 5 - 6
services/web/app/coffee/Features/Compile/CompileManager.coffee

@@ -31,15 +31,14 @@ module.exports = CompileManager =
 					DocumentUpdaterHandler.flushProjectToMongo project_id, (error) ->
 						return callback(error) if error?
 						ClsiManager.sendRequest project_id, (error, status, outputFiles) ->
-							return callback(error) if error?
-							logger.log files: outputFiles, "output files"
-							
-							if status == "failure"
-								# Sometimes compiles fail because the project gets in a broken
-								# state in LaTeX. So always clear cache on a failure.
+							if error?
+								# Sometimes compiles error because the project gets in a broken
+								# state in the CLSI. So always clear cache on an error.
 								# Can do this in the background.
 								ClsiManager.deleteAuxFiles project_id
+								return callback(error)
 
+							logger.log files: outputFiles, "output files"
 							callback(null, status, outputFiles)
 
 

+ 6 - 2
services/web/app/views/templates.jade

@@ -239,8 +239,12 @@
 	
 	script(type="text/template")#compileFailedTemplate
 		li.alert.alert-error
-			strong Ooops, your LaTeX code couldn't compile for some reason. Please check the errors below for details, or view the raw log.
-		
+			p
+				strong Compile Error. 
+				span Sorry, your LaTeX code couldn't compile for some reason. Please check the errors below for details, or view the raw log.
+			p
+				| If the problem persists, try 
+				a(href='#').js-clear-cache clearing the cache.
 	script(type="text/template")#compileTimeoutTemplate
 		li.alert.alert-error
 			strong Timed out. 

+ 2 - 0
services/web/public/coffee/pdf/CompiledView.coffee

@@ -117,6 +117,8 @@ define [
 				errorLogs.prepend($(@templates.compileError))
 			else if !pdfExists
 				errorLogs.prepend($(@templates.compileFailed))
+				errorLogs.find(".js-clear-cache").on "click", () =>
+					@options.manager.deleteCachedFiles()
 			else if pdfExists && compileErrors.all.length == 0
 				errorLogs.prepend($(@templates.compileSuccess))
 

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

@@ -76,16 +76,16 @@ describe "CompileManager", ->
 					.calledWith(project_id: @project_id, user_id: @user_id, "compiling project")
 					.should.equal true
 
-		describe "when the compile fails", ->
+		describe "when the compile errors", ->
 			beforeEach ->
 				@CompileManager._checkIfAutoCompileLimitHasBeenHit = (_, cb)-> cb(null, true)
 				@ClsiManager.deleteAuxFiles = sinon.stub()
-				@ClsiManager.sendRequest = sinon.stub().callsArgWith(1, null, @status = "failure")
+				@ClsiManager.sendRequest = sinon.stub().callsArgWith(1, @error = new Error("oops"), @status = "failure")
 				@CompileManager.compile @project_id, @user_id, {}, @callback
 
-			it "should call the callback", ->
+			it "should call the callback with the error", ->
 				@callback
-					.calledWith(null, @status)
+					.calledWith(@error)
 					.should.equal true
 
 			it "should clear the CLSI cache", ->