From f8da034e66c807c25b3385c5e566d54f4d891618 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Mon, 29 Jan 2024 14:54:18 +0200 Subject: [PATCH] Fail gracefully when remote icon is 404 --- app/services/app_catalog_manager/update_metadata.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/services/app_catalog_manager/update_metadata.rb b/app/services/app_catalog_manager/update_metadata.rb index 4530ae3..d78c5d8 100644 --- a/app/services/app_catalog_manager/update_metadata.rb +++ b/app/services/app_catalog_manager/update_metadata.rb @@ -45,8 +45,12 @@ module AppCatalogManager filename = "#{attachment_name}.png" key = "web_apps/#{@app.id}/icons/#{attachment_name}.png" - tempfile = Down.download(download_url) - @app.send(attachment_name).attach(key: key, io: tempfile, filename: filename) + begin + tempfile = Down.download(download_url) + @app.send(attachment_name).attach(key: key, io: tempfile, filename: filename) + rescue Down::NotFound + Rails.logger.warn "Icon download failed: NotFound error for #{download_url}" + end end end end