1
0
Fork 0
mirror of https://github.com/overleaf/overleaf.git synced 2025-04-08 13:52:02 +00:00

Be more forgiving with version mismatches

This commit is contained in:
James Allen 2014-04-15 08:02:49 +01:00
parent 953081c39d
commit eebfa6499e
2 changed files with 4 additions and 0 deletions
services/track-changes
app/coffee
test/unit/coffee/UpdatesManager

View file

@ -22,6 +22,7 @@ module.exports = UpdatesManager =
while rawUpdates[0]? and rawUpdates[0].v <= lastCompressedUpdate.v
rawUpdates.shift()
### TODO: Restore this when errors have died down after the Sunday crash.
if rawUpdates[0]? and rawUpdates[0].v != lastCompressedUpdate.v + 1
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, project_id: project_id, "inconsistent doc versions"
@ -30,6 +31,7 @@ module.exports = UpdatesManager =
MongoManager.insertCompressedUpdates project_id, doc_id, [lastCompressedUpdate], () ->
return callback error
return
###
compressedUpdates = UpdateCompressor.compressRawUpdates lastCompressedUpdate, rawUpdates
MongoManager.insertCompressedUpdates project_id, doc_id, compressedUpdates, (error) ->

View file

@ -104,6 +104,7 @@ describe "UpdatesManager", ->
.calledWith(@lastCompressedUpdate, @rawUpdates.slice(-2))
.should.equal true
###
describe "when the raw ops do not follow from the last compressed op version", ->
beforeEach ->
@rawUpdates = [{ v: 13, op: "mock-op-13" }]
@ -119,6 +120,7 @@ describe "UpdatesManager", ->
@MongoManager.insertCompressedUpdates
.calledWith(@project_id, @doc_id, [@lastCompressedUpdate])
.should.equal true
###
describe "processUncompressedUpdates", ->
beforeEach ->