Apply yield forcely

This commit is contained in:
Leeingnyo 2021-09-14 22:51:37 +09:00
parent 2e09efbd62
commit 670cf54957
3 changed files with 7 additions and 0 deletions

View File

@ -115,6 +115,7 @@ class Title
previous_entries_size = @entries.size
@entries.select! do |entry|
existence = File.exists? entry.zip_path
yield_process_file context
context["deleted_entry_ids"] << entry.id unless existence
existence
end

View File

@ -140,3 +140,8 @@ alias ExamineContext = NamedTuple(
deleted_title_ids: Array(String),
deleted_entry_ids: Array(String)
)
def yield_process_file(context : ExamineContext)
context["file_count"] += 1
Fiber.yield if context["file_count"] % 1000 == 0
end

View File

@ -56,6 +56,7 @@ class Dir
# directories)
def self.contents_signature(dirname, cache = {} of String => String) : String
return cache[dirname] if !cache.nil? && cache[dirname]?
Fiber.yield # Yield first
signatures = [] of String
self.open dirname do |dir|
dir.entries.sort.each do |fn|