Pass a counter to recursive calls, Ignore negative threshold

This commit is contained in:
Leeingnyo 2021-09-16 07:49:12 +09:00
parent 70ab198a33
commit 9769e760a0
2 changed files with 3 additions and 3 deletions

View File

@ -135,7 +135,7 @@ class TitleInfo
end
class YieldCounter
setter threshold : Int32
@file_count : UInt32
def initialize(@threshold : Int32)
@file_count = 0
@ -143,7 +143,7 @@ class YieldCounter
def count_and_yield
@file_count += 1
Fiber.yield if @file_count % @threshold == 0
Fiber.yield if @threshold > 0 && @file_count % @threshold == 0
end
end

View File

@ -65,7 +65,7 @@ class Dir
next if fn.starts_with? "."
path = File.join dirname, fn
if File.directory? path
signatures << Dir.contents_signature path, cache
signatures << Dir.contents_signature path, cache, counter
else
# Only add its signature value to `signatures` when it is a
# supported file