@@ -210,11 +210,14 @@ def batch_upload_images(run_id, image_files, client)
210210 }
211211
212212 used_filenames , = check_duplicate_files ( image_files , client )
213+ file_info_map = { }
213214
214215 @profiler . measure ( 'process_image_metadata' ) do
215216 image_files . each do |image_path |
216217 metadata_semaphore . async do
217218 file_info = client . parse_file_info ( image_path )
219+ file_name_without_extension = File . basename ( file_info [ :file_name ] , '.*' )
220+ file_info_map [ image_path ] = file_info
218221
219222 dimensions = @profiler . measure ( 'chunky_png_processing' ) do
220223 datastream = ChunkyPNG ::Datastream . from_file ( image_path )
@@ -225,15 +228,14 @@ def batch_upload_images(run_id, image_files, client)
225228 end
226229
227230 metadata = {
228- fileName : file_info [ :file_name ] ,
231+ fileName : file_name_without_extension ,
229232 groupName : file_info [ :group_name ] ,
230233 displayName : file_info [ :variant_name ] ,
231234 width : dimensions [ :width ] ,
232235 height : dimensions [ :height ]
233236 }
234237
235- image_name = File . basename ( image_path , '.*' )
236- image_metadata [ :images ] [ image_name ] = metadata
238+ image_metadata [ :images ] [ file_name_without_extension ] = metadata
237239 end
238240 end
239241
@@ -246,9 +248,9 @@ def batch_upload_images(run_id, image_files, client)
246248 zipfile . get_output_stream ( 'manifest.json' ) { |f | f . write ( JSON . generate ( image_metadata ) ) }
247249
248250 image_files . each do |image_path |
249- filename = File . basename ( image_path )
250- # Only add files we haven't seen before
251- zipfile . add ( filename , image_path ) if used_filenames [ filename ] == image_path
251+ file_info = file_info_map [ image_path ]
252+ # Only add files we haven't seen before, otherwise it will crash
253+ zipfile . add ( file_info [ :file_name ] , image_path ) if used_filenames [ file_info [ :file_name ] ] == image_path
252254 end
253255 end
254256 end
0 commit comments