From 2ab1778dd9dc858ff3d9478f0cf631782e76512d Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Wed, 23 Sep 2015 16:31:33 +0100 Subject: [PATCH] move default value of lastVersion into function body --- .../app/coffee/UpdatesManager.coffee | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/services/track-changes/app/coffee/UpdatesManager.coffee b/services/track-changes/app/coffee/UpdatesManager.coffee index 68507d7237..e1c9541748 100644 --- a/services/track-changes/app/coffee/UpdatesManager.coffee +++ b/services/track-changes/app/coffee/UpdatesManager.coffee @@ -14,10 +14,18 @@ module.exports = UpdatesManager = if length == 0 return callback() - MongoManager.popLastCompressedUpdate doc_id, (error, lastCompressedUpdate, lastVersion = lastCompressedUpdate?.v) -> - # lastCompressedUpdate may be null if we are forcing the start - # of a new compressed update, in which case we have the - # lastVersion to check consistency (defaults to lastCompressedUpdate.v) + MongoManager.popLastCompressedUpdate doc_id, (error, lastCompressedUpdate, lastVersion) -> + # lastCompressedUpdate is the most recent update in Mongo. + # + # The popLastCompressedUpdate method may pass it back as 'null' + # to force the start of a new compressed update, even when there + # was a previous compressed update in Mongo. In this case it + # passes back the lastVersion from the update to check + # consistency. + + # when lastVersion is not provided, default to lastCompressedUpdate.v + lastVersion ?= lastCompressedUpdate?.v + return callback(error) if error? # Ensure that raw updates start where lastVersion left off