mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Revert "change send doc lines using tpds to work with stream and doc store"
This reverts commit ba37710b087b4919c01eed3d8cfeb9d61af43a4d.
This commit is contained in:
parent
22c577f9b5
commit
93d418b716
5 changed files with 30 additions and 26 deletions
|
@ -86,7 +86,7 @@ module.exports = ProjectEntityHandler =
|
|||
for docPath, doc of docs
|
||||
do (docPath, doc) ->
|
||||
requests.push (callback) ->
|
||||
tpdsUpdateSender.addDoc {project_id:project_id, doc_id:doc._id, path:docPath, project_name:project.name, rev:doc.rev||0},
|
||||
tpdsUpdateSender.addDoc {project_id:project_id, docLines:doc.lines, path:docPath, project_name:project.name, rev:doc.rev||0},
|
||||
sl_req_id,
|
||||
callback
|
||||
self.getAllFiles project_id, (error, files) ->
|
||||
|
@ -127,7 +127,7 @@ module.exports = ProjectEntityHandler =
|
|||
return callback(err) if err?
|
||||
tpdsUpdateSender.addDoc {
|
||||
project_id: project._id,
|
||||
doc_id: doc._id
|
||||
docLines: docLines,
|
||||
path: result.path.fileSystem,
|
||||
project_name: project.name,
|
||||
rev: 0
|
||||
|
@ -256,7 +256,7 @@ module.exports = ProjectEntityHandler =
|
|||
if modified
|
||||
# Don't need to block for marking as updated
|
||||
projectUpdateHandler.markAsUpdated project_id
|
||||
tpdsUpdateSender.addDoc {project_id:project_id, path:path.fileSystem, doc_id:doc_id, project_name:project.name, rev:rev}, callback
|
||||
tpdsUpdateSender.addDoc {project_id:project_id, path:path.fileSystem, docLines:lines, project_name:project.name, rev:rev}, callback
|
||||
else
|
||||
callback()
|
||||
|
||||
|
|
|
@ -15,8 +15,10 @@ buildPath = (user_id, project_name, filePath)->
|
|||
queue = require('fairy').connect(settings.redis.fairy).queue(keys.queue.web_to_tpds_http_requests)
|
||||
|
||||
module.exports =
|
||||
|
||||
_addEntity: (options, sl_req_id, callback = (err)->)->
|
||||
|
||||
addFile : (options, sl_req_id, callback = (err)->)->
|
||||
metrics.inc("tpds.add-file")
|
||||
{callback, sl_req_id} = slReqIdHelper.getCallbackAndReqId(callback, sl_req_id)
|
||||
getProjectsUsersIds options.project_id, (err, user_id, allUserIds)->
|
||||
logger.log project_id: options.project_id, user_id:user_id, path: options.path, uri:options.uri, sl_req_id:sl_req_id, rev:options.rev, "sending file to third party data store"
|
||||
postOptions =
|
||||
|
@ -28,22 +30,28 @@ module.exports =
|
|||
sl_all_user_ids:JSON.stringify(allUserIds)
|
||||
uri : "#{settings.apis.thirdPartyDataStore.url}#{buildPath(user_id, options.project_name, options.path)}"
|
||||
title:"addFile"
|
||||
streamOrigin : options.streamOrigin
|
||||
streamOrigin : settings.apis.filestore.url + path.join("/project/#{options.project_id}/file/","#{options.file_id}")
|
||||
queue.enqueue options.project_id, "pipeStreamFrom", postOptions, ->
|
||||
logger.log project_id: options.project_id, user_id:user_id, path: options.path, uri:options.uri, sl_req_id:sl_req_id, rev:options.rev, "sending file to third party data store queued up for processing"
|
||||
callback()
|
||||
|
||||
addFile : (options, sl_req_id, callback = (err)->)->
|
||||
metrics.inc("tpds.add-file")
|
||||
{callback, sl_req_id} = slReqIdHelper.getCallbackAndReqId(callback, sl_req_id)
|
||||
options.streamOrigin = settings.apis.filestore.url + path.join("/project/#{options.project_id}/file/","#{options.file_id}")
|
||||
@_addEntity(options, sl_req_id, callback)
|
||||
|
||||
addDoc : (options, sl_req_id, callback = (err)->)->
|
||||
metrics.inc("tpds.add-doc")
|
||||
{callback, sl_req_id} = slReqIdHelper.getCallbackAndReqId(callback, sl_req_id)
|
||||
options.streamOrigin = settings.apis.docstore.url + path.join("/project/#{options.project_id}/doc/","#{options.doc_id}")
|
||||
@_addEntity(options, sl_req_id, callback)
|
||||
getProjectsUsersIds options.project_id, (err, user_id, allUserIds)->
|
||||
return callback(err) if err?
|
||||
logger.log project_id: options.project_id, user_id:user_id, path: options.path, rev:options.rev, uri:options.uri, project_name:options.project_name, docLines:options.docLines, sl_req_id:sl_req_id, "sending doc to third party data store"
|
||||
postOptions =
|
||||
method : "post"
|
||||
headers:
|
||||
"sl_req_id":sl_req_id,
|
||||
sl_entity_rev:options.rev,
|
||||
sl_project_id:options.project_id
|
||||
sl_all_user_ids:JSON.stringify(allUserIds)
|
||||
uri : "#{settings.apis.thirdPartyDataStore.url}#{buildPath(user_id, options.project_name, options.path)}"
|
||||
title: "addDoc"
|
||||
docLines: options.docLines
|
||||
queue.enqueue options.project_id, "sendDoc", postOptions, callback
|
||||
|
||||
|
||||
moveEntity : (options, sl_req_id, callback = (err)->)->
|
||||
|
|
|
@ -35,11 +35,10 @@ describe 'ProjectEntityHandler', ->
|
|||
@rev = 0
|
||||
save:(callback)->callback()
|
||||
rootFolder:[@rootFolder]
|
||||
|
||||
@DocModel = class Doc
|
||||
constructor:(options)->
|
||||
{@name, @lines} = options
|
||||
@_id = doc_id
|
||||
@_id = "mock-id"
|
||||
@rev = 0
|
||||
@FileModel = class File
|
||||
constructor:(options)->
|
||||
|
@ -327,7 +326,7 @@ describe 'ProjectEntityHandler', ->
|
|||
@tpdsUpdateSender.addDoc
|
||||
.calledWith({
|
||||
project_id: project_id
|
||||
doc_id: doc_id
|
||||
docLines: @lines
|
||||
path: @path
|
||||
project_name: @project.name
|
||||
rev: 0
|
||||
|
@ -505,7 +504,7 @@ describe 'ProjectEntityHandler', ->
|
|||
.calledWith({
|
||||
project_id: project_id
|
||||
project_name: @project.name
|
||||
doc_id: doc_id
|
||||
docLines: @lines
|
||||
rev: @rev
|
||||
path: @path
|
||||
})
|
||||
|
@ -700,7 +699,7 @@ describe 'ProjectEntityHandler', ->
|
|||
@tpdsUpdateSender.addDoc
|
||||
.calledWith({
|
||||
project_id: project_id,
|
||||
doc_id: doc._id
|
||||
docLines: doc.lines
|
||||
project_name: @project.name
|
||||
rev: doc.rev
|
||||
path: path
|
||||
|
|
|
@ -22,7 +22,6 @@ describe 'TpdsUpdateSender', ->
|
|||
@requestQueuer = regist:(queue, meth, opts, callback)->
|
||||
project = {owner_ref:user_id,readOnly_refs:[read_only_ref_1], collaberator_refs:[collaberator_ref_1]}
|
||||
@Project = findById:sinon.stub().callsArgWith(2, null, project)
|
||||
@docstoreUrl = "docstore.sharelatex.env"
|
||||
@updateSender = SandboxedModule.require modulePath, requires:
|
||||
'fairy':{connect:=>{queue:=>@requestQueuer}}
|
||||
"settings-sharelatex":
|
||||
|
@ -32,8 +31,6 @@ describe 'TpdsUpdateSender', ->
|
|||
thirdPartyDataStore: {url: thirdPartyDataStoreApiUrl}
|
||||
filestore:
|
||||
url: filestoreUrl
|
||||
docstore:
|
||||
url: @docstoreUrl
|
||||
redis:fairy:{}
|
||||
"logger-sharelatex":{log:->}
|
||||
'../../models/Project': Project:@Project
|
||||
|
@ -59,12 +56,12 @@ describe 'TpdsUpdateSender', ->
|
|||
path = "/some/path/here.tex"
|
||||
lines = ["line1", "line2", "line3"]
|
||||
|
||||
@requestQueuer.enqueue = (uid, method, job, callback)=>
|
||||
@requestQueuer.enqueue = (uid, method, job, callback)->
|
||||
uid.should.equal project_id
|
||||
job.method.should.equal "post"
|
||||
expectedUrl = "#{thirdPartyDataStoreApiUrl}/user/#{user_id}/entity/#{encodeURIComponent(project_name)}#{encodeURIComponent(path)}"
|
||||
job.uri.should.equal expectedUrl
|
||||
job.streamOrigin.should.equal "#{@docstoreUrl}/project/#{project_id}/doc/#{doc_id}"
|
||||
assert.deepEqual job.docLines, lines
|
||||
job.headers.sl_all_user_ids.should.eql(JSON.stringify([collaberator_ref_1, read_only_ref_1, user_id]))
|
||||
done()
|
||||
@updateSender.addDoc {project_id:project_id, doc_id:doc_id, path:path, docLines:lines,project_name:project_name}
|
||||
|
|
Loading…
Reference in a new issue