301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
|
# File 'supply/lib/supply/uploader.rb', line 301
def upload_screenshots(language)
Supply::SCREENSHOT_TYPES.each do |screenshot_type|
search = File.join(metadata_path, language, Supply::IMAGES_FOLDER_NAME, screenshot_type, "*.#{IMAGE_FILE_EXTENSIONS}")
paths = Dir.glob(search, File::FNM_CASEFOLD).sort
next unless paths.count > 0
if Supply.config[:sync_image_upload]
UI.message("🔍 Checking #{screenshot_type} checksums...")
existing_images = client.fetch_images(image_type: screenshot_type, language: language)
first_path_checksum = Digest::SHA256.file(paths.first).hexdigest
existing_images.each do |image|
if image.sha256 == first_path_checksum
UI.message("🟰 Skipping upload of screenshot #{paths.first} as remote sha256 matches.")
paths.shift first_path_checksum = paths.empty? ? nil : Digest::SHA256.file(paths.first).hexdigest
else
UI.message("🚮 Deleting #{language} screenshot id ##{image.id} as it does not exist locally or is out of order...")
client.clear_screenshot(image_type: screenshot_type, language: language, image_id: image.id)
end
end
else
client.clear_screenshots(image_type: screenshot_type, language: language)
end
paths.each do |path|
UI.message("⬆️ Uploading screenshot #{path}...")
client.upload_image(image_path: File.expand_path(path),
image_type: screenshot_type,
language: language)
end
end
end
|