mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Log out and put the last update back when an error occurs
This commit is contained in:
parent
e4d8cc7a11
commit
188d620ce1
2 changed files with 14 additions and 2 deletions
|
@ -21,7 +21,13 @@ module.exports = HistoryManager =
|
|||
rawUpdates.shift()
|
||||
|
||||
if rawUpdates[0]? and rawUpdates[0].v != lastCompressedUpdate.v + 1
|
||||
return callback new Error("Tried to apply raw op at version #{rawUpdates[0].v} to last compressed update with version #{lastCompressedUpdate.v}")
|
||||
error = new Error("Tried to apply raw op at version #{rawUpdates[0].v} to last compressed update with version #{lastCompressedUpdate.v}")
|
||||
logger.error err: error, doc_id: doc_id, "inconsistent doc versions"
|
||||
# Push the update back into Mongo - catching errors at this
|
||||
# point is useless, we're already bailing
|
||||
MongoManager.insertCompressedUpdates doc_id, [lastCompressedUpdate], () ->
|
||||
return callback error
|
||||
return
|
||||
|
||||
compressedUpdates = UpdateCompressor.compressRawUpdates lastCompressedUpdate, rawUpdates
|
||||
MongoManager.insertCompressedUpdates doc_id, compressedUpdates, (error) ->
|
||||
|
|
|
@ -12,7 +12,7 @@ describe "HistoryManager", ->
|
|||
"./MongoManager" : @MongoManager = {}
|
||||
"./RedisManager" : @RedisManager = {}
|
||||
"./LockManager" : @LockManager = {}
|
||||
"logger-sharelatex": { log: sinon.stub() }
|
||||
"logger-sharelatex": { log: sinon.stub(), error: sinon.stub() }
|
||||
@doc_id = "doc-id-123"
|
||||
@callback = sinon.stub()
|
||||
|
||||
|
@ -111,6 +111,12 @@ describe "HistoryManager", ->
|
|||
.calledWith(new Error("Tried to apply raw op at version 13 to last compressed update with version 11"))
|
||||
.should.equal true
|
||||
|
||||
it "should put the popped update back into mongo", ->
|
||||
@MongoManager.insertCompressedUpdates.calledOnce.should.equal true
|
||||
@MongoManager.insertCompressedUpdates
|
||||
.calledWith(@doc_id, [@lastCompressedUpdate])
|
||||
.should.equal true
|
||||
|
||||
describe "processUncompressedUpdates", ->
|
||||
describe "when there is fewer than one batch to send", ->
|
||||
beforeEach ->
|
||||
|
|
Loading…
Reference in a new issue