diff --git a/app/services/card_image_loading_service.rb b/app/services/card_image_loading_service.rb index f7dd2d8..a0c3afe 100644 --- a/app/services/card_image_loading_service.rb +++ b/app/services/card_image_loading_service.rb @@ -33,9 +33,10 @@ def import_disk(disk) logger.info("Fetching disk #{disk} file list") filenames = disk_array(disk) progress_bar.total += filenames.count - Sync do |task| + Sync do + semaphore = Async::Semaphore.new(100) filenames.map do |file_name| - task.async do + semaphore.async do progress_bar.increment find_or_create_card_image(file_name) end