Skip to content

Commit

Permalink
fix: refresh storage issues when language changes
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Sep 27, 2024
1 parent f3e5331 commit f305cf0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
1 change: 1 addition & 0 deletions service/lib/agama/storage/manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ def actions
# @param locale [String] new locale
def locale=(locale)
change_process_locale(locale)
update_issues
end

private
Expand Down
25 changes: 18 additions & 7 deletions service/lib/agama/storage/proposal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ def initialize(config, logger: nil)
@on_calculate_callbacks = []
end

# List of issues.
#
# @return [Array<Issue>]
attr_reader :issues

# Whether the proposal was already calculated.
#
# @return [Boolean]
Expand Down Expand Up @@ -192,6 +187,21 @@ def guided_settings
strategy_object.settings
end

# List of issues.
#
# @return [Array<Issue>]
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]
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f305cf0

Please sign in to comment.