Przeglądaj źródła

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

Brian Gough 11 lat temu
rodzic
commit
4c0eea9916

+ 4 - 1
services/track-changes/app/coffee/MongoManager.coffee

@@ -10,7 +10,10 @@ module.exports = MongoManager =
 			.limit(1)
 			.limit(1)
 			.toArray (error, compressedUpdates) ->
 			.toArray (error, compressedUpdates) ->
 				return callback(error) if error?
 				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
 				return callback null, compressedUpdates[0] or null
 
 
 	deleteCompressedUpdate: (id, callback = (error) ->) ->
 	deleteCompressedUpdate: (id, callback = (error) ->) ->