mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
gracefully handle updates marked as broken
set update.broken == true to allow the user to view history without a crash
This commit is contained in:
parent
8961e23954
commit
ad144371d0
2 changed files with 12 additions and 1 deletions
|
@ -14,7 +14,11 @@ module.exports = DiffManager =
|
|||
getDiff: (project_id, doc_id, fromVersion, toVersion, callback = (error, diff) ->) ->
|
||||
logger.log project_id: project_id, doc_id: doc_id, from: fromVersion, to: toVersion, "getting diff"
|
||||
DiffManager.getDocumentBeforeVersion project_id, doc_id, fromVersion, (error, startingContent, updates) ->
|
||||
return callback(error) if error?
|
||||
if error?
|
||||
if error.message == "broken-history"
|
||||
return callback(null, "history unavailable")
|
||||
else
|
||||
return callback(error)
|
||||
|
||||
updatesToApply = []
|
||||
for update in updates.slice().reverse()
|
||||
|
@ -33,6 +37,10 @@ module.exports = DiffManager =
|
|||
DiffManager.getLatestDocAndUpdates project_id, doc_id, version, null, (error, content, version, updates) ->
|
||||
return callback(error) if error?
|
||||
|
||||
# bail out if we hit a broken update
|
||||
for u in updates when u.broken
|
||||
return callback new Error "broken-history"
|
||||
|
||||
lastUpdate = updates[0]
|
||||
if lastUpdate? and lastUpdate.v != version - 1
|
||||
return callback new Error("latest update version, #{lastUpdate.v}, does not match doc version, #{version}")
|
||||
|
|
|
@ -33,6 +33,9 @@ module.exports = MongoManager =
|
|||
# we want to force a new update, but ensure that it is
|
||||
# consistent with the version of the existing one in S3
|
||||
return callback null, null, update.v
|
||||
else if update.broken
|
||||
# the update is marked as broken so we will force a new op
|
||||
return callback null, null
|
||||
else
|
||||
MongoManager.deleteCompressedUpdate update._id, (error) ->
|
||||
return callback(error) if error?
|
||||
|
|
Loading…
Reference in a new issue