]> git.saurik.com Git - redis.git/commitdiff
Merge pull request #181 from redsquirrel/unstable
authorSalvatore Sanfilippo <antirez@gmail.com>
Tue, 15 Nov 2011 14:36:53 +0000 (06:36 -0800)
committerSalvatore Sanfilippo <antirez@gmail.com>
Tue, 15 Nov 2011 14:36:53 +0000 (06:36 -0800)
Fixing inject: it was failing when there was 1 or >2 sources

src/redis-trib.rb

index fa0e8c6dd90305e6ea296342429ae83f95b50f98..473e492292912d60cbafbcaf917d24c61183b36a 100755 (executable)
@@ -319,7 +319,7 @@ class RedisTrib
         #    divisibility. Like we have 3 nodes and need to get 10 slots, we take
         #    4 from the first, and 3 from the rest. So the biggest is always the first.
         sources = sources.sort{|a,b| b.slots.length <=> a.slots.length}
-        source_tot_slots = sources.inject {|a,b| a.slots.length+b.slots.length}
+        source_tot_slots = sources.inject(0) {|sum,source| sum+source.slots.length}
         sources.each_with_index{|s,i|
             # Every node will provide a number of slots proportional to the
             # slots it has assigned.