From 07f078b5276eb9ef9773abc4dd1259aae6a345a1 Mon Sep 17 00:00:00 2001 From: James Allen Date: Fri, 9 Aug 2013 13:46:03 +0100 Subject: [PATCH] Don't insert a null update if there are no updates or raw updates --- services/track-changes/app/coffee/ConversionManager.coffee | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/services/track-changes/app/coffee/ConversionManager.coffee b/services/track-changes/app/coffee/ConversionManager.coffee index 5dca40a476..2821c057be 100644 --- a/services/track-changes/app/coffee/ConversionManager.coffee +++ b/services/track-changes/app/coffee/ConversionManager.coffee @@ -59,6 +59,10 @@ module.exports = ConversionManager = if !lastCompressedUpdate? lastCompressedUpdate = rawUpdates.shift() + if !lastCompressedUpdate? + # No saved versions, no raw updates, nothing to do + callback() + compressedUpdates = [lastCompressedUpdate] for rawUpdate in rawUpdates lastCompressedUpdate = compressedUpdates.pop() @@ -69,5 +73,5 @@ module.exports = ConversionManager = ConversionManager.insertCompressedUpdates doc_id, compressedUpdates, (error) -> return callback(error) if error? console.log doc_id, "Pushed doc ops", length - callback null, true + callback()