From 92dd4d57d5886abfec7b2f663e05d4e3ffabf1b0 Mon Sep 17 00:00:00 2001 From: Erik Berlin Date: Tue, 10 Dec 2024 13:15:02 -0800 Subject: [PATCH] Add inline type annotation for empty array --- lib/x/media_uploader.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/x/media_uploader.rb b/lib/x/media_uploader.rb index f6c6bc9..cfe24ed 100644 --- a/lib/x/media_uploader.rb +++ b/lib/x/media_uploader.rb @@ -66,16 +66,16 @@ def infer_media_type(file_path, media_category) def split(file_path, chunk_size) file_number = -1 + file_paths = [] # @type var file_paths: Array[String] - [].tap do |file_paths| - File.open(file_path, "rb") do |f| - while (chunk = f.read(chunk_size)) - file_paths << "#{Dir.mktmpdir}/x#{format("%03d", file_number += 1)}".tap do |path| - File.binwrite(path, chunk) - end - end + File.open(file_path, "rb") do |f| + while (chunk = f.read(chunk_size)) + path = "#{Dir.mktmpdir}/x#{format("%03d", file_number += 1)}" + File.binwrite(path, chunk) + file_paths << path end end + file_paths end def init(upload_client:, file_path:, media_type:, media_category:)