mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-24 03:33:27 +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)
|
||||
|
||||
_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()
|
||||
synctexDir = Path.dirname(path)
|
||||
synctexFile = Path.join(synctexDir, "output.synctex.gz")
|
||||
fs.stat synctexDir, (error, stats) ->
|
||||
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) ->) ->
|
||||
bin_path = Path.resolve(__dirname + "/../../bin/synctex")
|
||||
seconds = 1000
|
||||
outputFilePath = args[1]
|
||||
CompileManager._checkFileExists outputFilePath, (err) ->
|
||||
CompileManager._checkFileExists outputFilePath, (error) ->
|
||||
return callback(error) if error?
|
||||
if Settings.clsi?.synctexCommandWrapper?
|
||||
[bin_path, args] = Settings.clsi?.synctexCommandWrapper bin_path, args
|
||||
child_process.execFile bin_path, args, timeout: 10 * seconds, (error, stdout, stderr) ->
|
||||
|
|
Loading…
Reference in a new issue