mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-24 18:22:01 +00:00
check directory exists and bail out on error
This commit is contained in:
parent
42fa852b76
commit
550979991f
1 changed files with 14 additions and 5 deletions
|
@ -202,16 +202,25 @@ module.exports = CompileManager =
|
||||||
callback null, CompileManager._parseSynctexFromPdfOutput(stdout, base_dir)
|
callback null, CompileManager._parseSynctexFromPdfOutput(stdout, base_dir)
|
||||||
|
|
||||||
_checkFileExists: (path, callback = (error) ->) ->
|
_checkFileExists: (path, callback = (error) ->) ->
|
||||||
fs.stat path, (err, stats) ->
|
synctexDir = Path.dirname(path)
|
||||||
return callback(err) if err?
|
synctexFile = Path.join(synctexDir, "output.synctex.gz")
|
||||||
return callback(new Error("not a file")) if not stats.isFile()
|
fs.stat synctexDir, (error, stats) ->
|
||||||
callback()
|
if error?.code is 'ENOENT'
|
||||||
|
return callback(new Error("called synctex with no output directory"))
|
||||||
|
return callback(error) if error?
|
||||||
|
fs.stat synctexFile, (error, stats) ->
|
||||||
|
if error?.code is 'ENOENT'
|
||||||
|
return callback(new Error("called synctex with no output file"))
|
||||||
|
return callback(error) if error?
|
||||||
|
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
|
||||||
outputFilePath = args[1]
|
outputFilePath = args[1]
|
||||||
CompileManager._checkFileExists outputFilePath, (err) ->
|
CompileManager._checkFileExists outputFilePath, (error) ->
|
||||||
|
return callback(error) if error?
|
||||||
if Settings.clsi?.synctexCommandWrapper?
|
if Settings.clsi?.synctexCommandWrapper?
|
||||||
[bin_path, args] = Settings.clsi?.synctexCommandWrapper bin_path, args
|
[bin_path, args] = Settings.clsi?.synctexCommandWrapper bin_path, args
|
||||||
child_process.execFile bin_path, args, timeout: 10 * seconds, (error, stdout, stderr) ->
|
child_process.execFile bin_path, args, timeout: 10 * seconds, (error, stdout, stderr) ->
|
||||||
|
|
Loading…
Reference in a new issue