From d282ebf9bd58acb7f394e2ec0dadab984f678a2e Mon Sep 17 00:00:00 2001 From: Christian Bruckmayer Date: Tue, 27 Aug 2024 13:39:26 +0100 Subject: [PATCH] Raise error when progress is negative --- ruby/lib/ci/queue/redis/base.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ruby/lib/ci/queue/redis/base.rb b/ruby/lib/ci/queue/redis/base.rb index 750b729d..d4debe23 100644 --- a/ruby/lib/ci/queue/redis/base.rb +++ b/ruby/lib/ci/queue/redis/base.rb @@ -133,8 +133,12 @@ def to_a end.flatten.reverse.map { |k| index.fetch(k) } end + ImplausibleProgress = Class.new(StandardError) + def progress - total - size + result = total - size + raise ImplausibleProgress, "Progress cannot be negative (#{result} (#{total} - #{size}))" if result < 0 + result end def wait_for_master(timeout: 30)