From c6de24bf3453d888178047cbf0c32bf22ff02427 Mon Sep 17 00:00:00 2001 From: Cyberarm Date: Thu, 8 Oct 2026 10:28:40 -0500 Subject: [PATCH] Fix not generating png from application ico if ico file exists --- lib/gui_ext.rb | 14 ++++++++++++-- lib/pages/games.rb | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/gui_ext.rb b/lib/gui_ext.rb index 9dc55a0..0bbf44a 100644 --- a/lib/gui_ext.rb +++ b/lib/gui_ext.rb @@ -32,10 +32,12 @@ module W3DHubLauncher end # Downloads requested url and on success check if host element is still in the layout and call the block if so. - def remote_image(path, url:, element:, &block) + def remote_image(path, url:, element:, required_path: nil, &block) memcache_key = :"lock_net_download_#{element.style.tag}" - if !File.exist?(path) && MemCache[memcache_key].nil? + path_exists = File.exist?(path) + + if !path_exists && MemCache[memcache_key].nil? MemCache[memcache_key] = true Worker::Api.download_url(url, path) do |result| @@ -53,6 +55,14 @@ module W3DHubLauncher end end end + + if required_path && path_exists && !File.exist?(required_path) + e = find_element_by_tag(element.root, element.style.tag) + + return unless e + + block.call(element, path) + end end def on_main_thread(block) diff --git a/lib/pages/games.rb b/lib/pages/games.rb index 44629de..e4fe3de 100644 --- a/lib/pages/games.rb +++ b/lib/pages/games.rb @@ -154,7 +154,7 @@ module W3DHubLauncher btn = button(safe_get_image("#{CACHE_PATH}/icon_#{game.id}.png"), tag: :"image_icon_#{game.id}", style_class: [:app_icon_button], enabled: @current_app.id != game.id, tip: game.name) do |btn| populate_game(game, game&.channels&.first) end - remote_image("#{CACHE_PATH}/icon_#{game.id}.ico", url: "https://s3.w3d.cyberarm.dev/games/#{game.id}/#{game.id}.ico", element: btn) do |e, path| + remote_image("#{CACHE_PATH}/icon_#{game.id}.ico", required_path: "#{CACHE_PATH}/icon_#{game.id}.png", url: "https://s3.w3d.cyberarm.dev/games/#{game.id}/#{game.id}.ico", element: btn) do |e, path| Worker::Api.ico_to_png(ico_path: path, png_path: path.sub(".ico", ".png")) do |result| e&.value = safe_get_image(result.data["path"]) if result.okay? end