Просмотр исходного кода

return an error if trying to pop the last update from a pack

Brian Gough 11 лет назад
Родитель
Сommit
4c0eea9916
1 измененных файлов с 4 добавлено и 1 удалено
  1. 4 1
      services/track-changes/app/coffee/MongoManager.coffee

+ 4 - 1
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) ->) ->