mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
queue doc content sync updates
This commit is contained in:
parent
52d6b710bd
commit
d46217be52
3 changed files with 37 additions and 12 deletions
|
@ -179,6 +179,17 @@ module.exports = DocumentManager =
|
|||
else
|
||||
callback(null, lines, version)
|
||||
|
||||
resyncDocContents: (project_id, doc_id, callback) ->
|
||||
RedisManager.getDoc project_id, doc_id, (error, lines, version, ranges, pathname) ->
|
||||
return callback(error) if error?
|
||||
|
||||
if !lines? or !version?
|
||||
PersistenceManager.getDoc project_id, doc_id, (error, lines, version, ranges, pathname) ->
|
||||
return callback(error) if error?
|
||||
RedisManager.queueResyncDocContents project_id, doc_id, lines, version, pathname, callback
|
||||
else
|
||||
RedisManager.queueResyncDocContents project_id, doc_id, lines, version, pathname, callback
|
||||
|
||||
getDocWithLock: (project_id, doc_id, callback = (error, lines, version) ->) ->
|
||||
UpdateManager = require "./UpdateManager"
|
||||
UpdateManager.lockUpdatesAndDo DocumentManager.getDoc, project_id, doc_id, callback
|
||||
|
@ -214,3 +225,7 @@ module.exports = DocumentManager =
|
|||
renameDocWithLock: (project_id, doc_id, user_id, update, callback = (error) ->) ->
|
||||
UpdateManager = require "./UpdateManager"
|
||||
UpdateManager.lockUpdatesAndDo DocumentManager.renameDoc, project_id, doc_id, user_id, update, callback
|
||||
|
||||
resyncDocContentsWithLock: (project_id, doc_id, callback = (error) ->) ->
|
||||
UpdateManager = require "./UpdateManager"
|
||||
UpdateManager.lockUpdatesAndDo DocumentManager.resyncDocContents, project_id, doc_id, callback
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
Settings = require "settings-sharelatex"
|
||||
request = require "request"
|
||||
async = require "async"
|
||||
logger = require "logger-sharelatex"
|
||||
request = require "request"
|
||||
Settings = require "settings-sharelatex"
|
||||
HistoryRedisManager = require "./HistoryRedisManager"
|
||||
RedisManager = require "./RedisManager"
|
||||
|
||||
|
@ -64,12 +65,9 @@ module.exports = HistoryManager =
|
|||
return newBlock != prevBlock
|
||||
|
||||
resyncProject: (project_id, docs, files, callback) ->
|
||||
RedisManager.resyncProjectStructure project_id, docs, files, (error) ->
|
||||
RedisManager.queueResyncProjectStructure project_id, docs, files, (error) ->
|
||||
return callback(error) if error?
|
||||
callback null
|
||||
|
||||
#jobs = _.union
|
||||
#_.map docs, (doc) -> RedisManager.resyncDoc project_id, doc
|
||||
#_.map files, (files) -> RedisManager.resyncFile project_id, file
|
||||
|
||||
#async.series jobs, callback
|
||||
DocumentManager = require "./DocumentManager"
|
||||
resyncDoc = (doc, cb) ->
|
||||
DocumentManager.resyncDocContentsWithLock project_id, doc.doc, cb
|
||||
async.each docs, resyncDoc, callback
|
||||
|
|
|
@ -321,9 +321,21 @@ module.exports = RedisManager =
|
|||
getDocIdsInProject: (project_id, callback = (error, doc_ids) ->) ->
|
||||
rclient.smembers keys.docsInProject(project_id: project_id), callback
|
||||
|
||||
resyncProjectStructure: (project_id, docs, files, callback) ->
|
||||
queueResyncProjectStructure: (project_id, docs, files, callback) ->
|
||||
update =
|
||||
projectStructure: { docs, files }
|
||||
resyncProjectStructure: { docs, files }
|
||||
meta:
|
||||
ts: new Date()
|
||||
jsonUpdate = JSON.stringify update
|
||||
rclient.rpush projectHistoryKeys.projectHistoryOps({project_id}), jsonUpdate, callback
|
||||
|
||||
queueResyncDocContents: (project_id, doc_id, lines, version, pathname, callback) ->
|
||||
update =
|
||||
resyncDocContents:
|
||||
content: lines.join("\n"),
|
||||
version: version
|
||||
path: pathname
|
||||
doc: doc_id
|
||||
meta:
|
||||
ts: new Date()
|
||||
jsonUpdate = JSON.stringify update
|
||||
|
|
Loading…
Reference in a new issue