check file exists before running synctex
This commit is contained in:
@@ -201,16 +201,24 @@ module.exports = CompileManager =
|
|||||||
logger.log project_id: project_id, user_id:user_id, page: page, h: h, v:v, stdout: stdout, "synctex pdf output"
|
logger.log project_id: project_id, user_id:user_id, page: page, h: h, v:v, stdout: stdout, "synctex pdf output"
|
||||||
callback null, CompileManager._parseSynctexFromPdfOutput(stdout, base_dir)
|
callback null, CompileManager._parseSynctexFromPdfOutput(stdout, base_dir)
|
||||||
|
|
||||||
|
_checkFileExists: (path, callback = (error) ->) ->
|
||||||
|
fs.stat path, (err, stats) ->
|
||||||
|
return callback(err) if err?
|
||||||
|
return callback(new Error("not a file")) if not stats.isFile()
|
||||||
|
callback()
|
||||||
|
|
||||||
_runSynctex: (args, callback = (error, stdout) ->) ->
|
_runSynctex: (args, callback = (error, stdout) ->) ->
|
||||||
bin_path = Path.resolve(__dirname + "/../../bin/synctex")
|
bin_path = Path.resolve(__dirname + "/../../bin/synctex")
|
||||||
seconds = 1000
|
seconds = 1000
|
||||||
if Settings.clsi?.synctexCommandWrapper?
|
outputFilePath = args[1]
|
||||||
[bin_path, args] = Settings.clsi?.synctexCommandWrapper bin_path, args
|
CompileManager._checkFileExists outputFilePath, (err) ->
|
||||||
child_process.execFile bin_path, args, timeout: 10 * seconds, (error, stdout, stderr) ->
|
if Settings.clsi?.synctexCommandWrapper?
|
||||||
if error?
|
[bin_path, args] = Settings.clsi?.synctexCommandWrapper bin_path, args
|
||||||
logger.err err:error, args:args, "error running synctex"
|
child_process.execFile bin_path, args, timeout: 10 * seconds, (error, stdout, stderr) ->
|
||||||
return callback(error)
|
if error?
|
||||||
callback(null, stdout)
|
logger.err err:error, args:args, "error running synctex"
|
||||||
|
return callback(error)
|
||||||
|
callback(null, stdout)
|
||||||
|
|
||||||
_parseSynctexFromCodeOutput: (output) ->
|
_parseSynctexFromCodeOutput: (output) ->
|
||||||
results = []
|
results = []
|
||||||
|
|||||||
@@ -192,6 +192,7 @@ describe "CompileManager", ->
|
|||||||
|
|
||||||
describe "syncFromCode", ->
|
describe "syncFromCode", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
|
@fs.stat = sinon.stub().callsArgWith(1, null,{isFile: ()->true})
|
||||||
@child_process.execFile.callsArgWith(3, null, @stdout = "NODE\t#{@page}\t#{@h}\t#{@v}\t#{@width}\t#{@height}\n", "")
|
@child_process.execFile.callsArgWith(3, null, @stdout = "NODE\t#{@page}\t#{@h}\t#{@v}\t#{@width}\t#{@height}\n", "")
|
||||||
@CompileManager.syncFromCode @project_id, @user_id, @file_name, @line, @column, @callback
|
@CompileManager.syncFromCode @project_id, @user_id, @file_name, @line, @column, @callback
|
||||||
|
|
||||||
@@ -216,6 +217,7 @@ describe "CompileManager", ->
|
|||||||
|
|
||||||
describe "syncFromPdf", ->
|
describe "syncFromPdf", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
|
@fs.stat = sinon.stub().callsArgWith(1, null,{isFile: ()->true})
|
||||||
@child_process.execFile.callsArgWith(3, null, @stdout = "NODE\t#{@Settings.path.compilesDir}/#{@project_id}-#{@user_id}/#{@file_name}\t#{@line}\t#{@column}\n", "")
|
@child_process.execFile.callsArgWith(3, null, @stdout = "NODE\t#{@Settings.path.compilesDir}/#{@project_id}-#{@user_id}/#{@file_name}\t#{@line}\t#{@column}\n", "")
|
||||||
@CompileManager.syncFromPdf @project_id, @user_id, @page, @h, @v, @callback
|
@CompileManager.syncFromPdf @project_id, @user_id, @page, @h, @v, @callback
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user