mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
only flush to track-changes when ops are queued
This commit is contained in:
parent
529a061567
commit
7a9577e081
3 changed files with 14 additions and 1 deletions
|
@ -91,7 +91,7 @@ module.exports = DocumentManager =
|
||||||
logger.log project_id: project_id, doc_id: doc_id, version: version, "flushing doc"
|
logger.log project_id: project_id, doc_id: doc_id, version: version, "flushing doc"
|
||||||
PersistenceManager.setDoc project_id, doc_id, lines, version, (error) ->
|
PersistenceManager.setDoc project_id, doc_id, lines, version, (error) ->
|
||||||
return callback(error) if error?
|
return callback(error) if error?
|
||||||
TrackChangesManager.flushDocChanges project_id, doc_id, (error) ->
|
TrackChangesManager.flushDocChangesIfNeeded project_id, doc_id, (error) ->
|
||||||
return callback(error) if error?
|
return callback(error) if error?
|
||||||
callback null
|
callback null
|
||||||
|
|
||||||
|
|
|
@ -171,6 +171,9 @@ module.exports = RedisManager =
|
||||||
[length, _] = results
|
[length, _] = results
|
||||||
callback(error, length)
|
callback(error, length)
|
||||||
|
|
||||||
|
getUncompressedHistoryOpLength: (doc_id, callback = (error, length) ->) ->
|
||||||
|
rclient.llen keys.uncompressedHistoryOp(doc_id: doc_id), callback
|
||||||
|
|
||||||
getDocOpsLength: (doc_id, callback = (error, length) ->) ->
|
getDocOpsLength: (doc_id, callback = (error, length) ->) ->
|
||||||
rclient.llen keys.docOps(doc_id: doc_id), callback
|
rclient.llen keys.docOps(doc_id: doc_id), callback
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,16 @@ RedisManager = require "./RedisManager"
|
||||||
crypto = require("crypto")
|
crypto = require("crypto")
|
||||||
|
|
||||||
module.exports = TrackChangesManager =
|
module.exports = TrackChangesManager =
|
||||||
|
|
||||||
|
flushDocChangesIfNeeded: (project_id, doc_id, callback = (error) ->) ->
|
||||||
|
RedisManager.getUncompressedHistoryOpLength doc_id, (error, length) ->
|
||||||
|
return callback(error) if error?
|
||||||
|
if length > 0
|
||||||
|
# only make request to track changes if there are queued ops
|
||||||
|
TrackChangesManager.flushDocChanges project_id, doc_id, callback
|
||||||
|
else
|
||||||
|
callback()
|
||||||
|
|
||||||
flushDocChanges: (project_id, doc_id, callback = (error) ->) ->
|
flushDocChanges: (project_id, doc_id, callback = (error) ->) ->
|
||||||
if !settings.apis?.trackchanges?
|
if !settings.apis?.trackchanges?
|
||||||
logger.warn doc_id: doc_id, "track changes API is not configured, so not flushing"
|
logger.warn doc_id: doc_id, "track changes API is not configured, so not flushing"
|
||||||
|
|
Loading…
Reference in a new issue