From 4c0eea99168a1d04daf14a4744b46ee284341f3a Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Tue, 17 Feb 2015 14:53:50 +0000 Subject: [PATCH] return an error if trying to pop the last update from a pack --- services/track-changes/app/coffee/MongoManager.coffee | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/services/track-changes/app/coffee/MongoManager.coffee b/services/track-changes/app/coffee/MongoManager.coffee index db17cdfc1c..b1ea5cb180 100644 --- a/services/track-changes/app/coffee/MongoManager.coffee +++ b/services/track-changes/app/coffee/MongoManager.coffee @@ -10,7 +10,10 @@ module.exports = MongoManager = .limit(1) .toArray (error, compressedUpdates) -> return callback(error) if error? - return callback null, null if compressedUpdates[0]?.pack? # cannot pop from a pack + if compressedUpdates[0]?.pack? + # cannot pop from a pack, throw error + error = new Error("last compressed update is a pack") + return callback error, null return callback null, compressedUpdates[0] or null deleteCompressedUpdate: (id, callback = (error) ->) ->