From f305cf0aa693f420a3d4e3426aed0b7af4737a44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Imobach=20Gonz=C3=A1lez=20Sosa?= Date: Fri, 27 Sep 2024 06:36:33 +0100 Subject: [PATCH] fix: refresh storage issues when language changes --- service/lib/agama/storage/manager.rb | 1 + service/lib/agama/storage/proposal.rb | 25 ++++++++++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/service/lib/agama/storage/manager.rb b/service/lib/agama/storage/manager.rb index 1d4faf9f9c..2cd5546abf 100644 --- a/service/lib/agama/storage/manager.rb +++ b/service/lib/agama/storage/manager.rb @@ -179,6 +179,7 @@ def actions # @param locale [String] new locale def locale=(locale) change_process_locale(locale) + update_issues end private diff --git a/service/lib/agama/storage/proposal.rb b/service/lib/agama/storage/proposal.rb index f8d014e04f..c5499636c9 100644 --- a/service/lib/agama/storage/proposal.rb +++ b/service/lib/agama/storage/proposal.rb @@ -45,11 +45,6 @@ def initialize(config, logger: nil) @on_calculate_callbacks = [] end - # List of issues. - # - # @return [Array] - attr_reader :issues - # Whether the proposal was already calculated. # # @return [Boolean] @@ -192,6 +187,21 @@ def guided_settings strategy_object.settings end + # List of issues. + # + # @return [Array] + def issues + return [] unless storage_manager.probed? + + updated = [] + if proposal&.failed? || @calculate_error.is_a?(Y2Storage::NoDiskSpaceError) + updated << failed_issue + end + updated << failed_issue if proposal.failed? + updated.concat(strategy_object.issues) + updated + end + private # @return [Agama::Config] @@ -232,13 +242,14 @@ def calculate_agama_from_json(storage_json) def calculate return false unless storage_manager.probed? - @issues = [] + @calculate_error = nil begin strategy_object.calculate @issues << failed_issue if proposal.failed? rescue Y2Storage::Error => e - handle_exception(e) + @calculate_error = e + raise e end @issues.concat(strategy_object.issues)