mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Move Clsi logic to ClsiManager
This commit is contained in:
parent
54cdbd738c
commit
d93eb448e3
2 changed files with 12 additions and 7 deletions
|
@ -182,6 +182,14 @@ module.exports = ClsiManager =
|
|||
return callback(error) if error?
|
||||
callback(null, projectStateHash, docs)
|
||||
|
||||
getOutputFileStream: (project_id, output_file_path, callback=(err, readStream)->) ->
|
||||
url = "#{Settings.apis.clsi.url}/project/#{project_id}/output/#{output_file_path}"
|
||||
ClsiCookieManager.getCookieJar project_id, (err, jar)->
|
||||
return callback(err) if err?
|
||||
options = { url: url, method: "GET", timeout: 60 * 1000, jar : jar }
|
||||
readStream = request(options)
|
||||
callback(null, readStream)
|
||||
|
||||
_buildRequestFromDocupdater: (project_id, options, project, projectStateHash, docUpdaterDocs, callback = (error, request) ->) ->
|
||||
ProjectEntityHandler.getAllDocPathsFromProject project, (error, docPath) ->
|
||||
return callback(error) if error?
|
||||
|
|
|
@ -4,8 +4,8 @@ ProjectGetter = require('../Project/ProjectGetter')
|
|||
FileWriter = require('../../infrastructure/FileWriter')
|
||||
Settings = require 'settings-sharelatex'
|
||||
CompileManager = require '../Compile/CompileManager'
|
||||
CompileController = require '../Compile/CompileController'
|
||||
ClsiCookieManager = require '../Compile/ClsiCookieManager'
|
||||
ClsiManager = require '../Compile/ClsiManager'
|
||||
ProjectFileAgent = require './ProjectFileAgent'
|
||||
_ = require "underscore"
|
||||
request = require "request"
|
||||
|
@ -59,16 +59,13 @@ module.exports = ProjectOutputFileAgent = {
|
|||
source_project_id = project._id
|
||||
CompileManager.compile source_project_id, null, {}, (err) ->
|
||||
return callback(err) if err?
|
||||
url = "#{Settings.apis.clsi.url}/project/#{source_project_id}/output/#{source_output_file_path}"
|
||||
ClsiCookieManager.getCookieJar source_project_id, (err, jar)->
|
||||
ClsiManager.getOutputFileStream source_project_id, source_output_file_path, (err, readStream) ->
|
||||
return callback(err) if err?
|
||||
oneMinute = 60 * 1000
|
||||
# the base request
|
||||
options = { url: url, method: "GET", timeout: oneMinute, jar : jar }
|
||||
readStream = request(options)
|
||||
readStream.pause()
|
||||
readStream.on "error", callback
|
||||
readStream.on "response", (response) ->
|
||||
if 200 <= response.statusCode < 300
|
||||
readStream.resume()
|
||||
FileWriter.writeStreamToDisk project_id, readStream, callback
|
||||
else
|
||||
error = new OutputFileFetchFailedError("Output file fetch failed: #{url}")
|
||||
|
|
Loading…
Reference in a new issue