mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #36 from sharelatex/bg-limit-resync-requests-to-web
limit resync requests to web (connects to overleaf/sharelatex#775)
This commit is contained in:
commit
537bd9a0c0
2 changed files with 9 additions and 2 deletions
|
@ -181,14 +181,19 @@ module.exports = DocumentManager =
|
|||
callback(null, lines, version)
|
||||
|
||||
resyncDocContents: (project_id, doc_id, callback) ->
|
||||
logger.log {project_id: project_id, doc_id: doc_id}, "start resyncing doc contents"
|
||||
RedisManager.getDoc project_id, doc_id, (error, lines, version, ranges, pathname, projectHistoryId) ->
|
||||
return callback(error) if error?
|
||||
|
||||
if !lines? or !version?
|
||||
logger.log {project_id: project_id, doc_id: doc_id}, "resyncing doc contents - not found in redis - retrieving from web"
|
||||
PersistenceManager.getDoc project_id, doc_id, (error, lines, version, ranges, pathname, projectHistoryId) ->
|
||||
return callback(error) if error?
|
||||
if error?
|
||||
logger.error {project_id: project_id, doc_id: doc_id, getDocError: error}, "resyncing doc contents - error retrieving from web"
|
||||
return callback(error)
|
||||
ProjectHistoryRedisManager.queueResyncDocContent project_id, projectHistoryId, doc_id, lines, version, pathname, callback
|
||||
else
|
||||
logger.log {project_id: project_id, doc_id: doc_id}, "resyncing doc contents - doc in redis - will queue in redis"
|
||||
ProjectHistoryRedisManager.queueResyncDocContent project_id, projectHistoryId, doc_id, lines, version, pathname, callback
|
||||
|
||||
getDocWithLock: (project_id, doc_id, callback = (error, lines, version) ->) ->
|
||||
|
|
|
@ -65,10 +65,12 @@ module.exports = HistoryManager =
|
|||
newBlock = Math.floor(length / threshold)
|
||||
return newBlock != prevBlock
|
||||
|
||||
MAX_PARALLEL_REQUESTS: 4
|
||||
|
||||
resyncProjectHistory: (project_id, projectHistoryId, docs, files, callback) ->
|
||||
ProjectHistoryRedisManager.queueResyncProjectStructure project_id, projectHistoryId, docs, files, (error) ->
|
||||
return callback(error) if error?
|
||||
DocumentManager = require "./DocumentManager"
|
||||
resyncDoc = (doc, cb) ->
|
||||
DocumentManager.resyncDocContentsWithLock project_id, doc.doc, cb
|
||||
async.each docs, resyncDoc, callback
|
||||
async.eachLimit docs, HistoryManager.MAX_PARALLEL_REQUESTS, resyncDoc, callback
|
||||
|
|
Loading…
Reference in a new issue