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 2d984ed
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 22 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
45 changes: 23 additions & 22 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,25 @@ def guided_settings
strategy_object.settings
end

# List of issues.
#
# @return [Array<Issue>]
def issues
items = []

case @calculate_error
when Y2Storage::NoDiskSpaceError
items << failed_issue
when Y2Storage::Error
items << exception_issue(@calculate_error)
else
items << failed_issue if proposal&.failed?
end

items.concat(strategy_object.issues) if strategy_object
items
end

private

# @return [Agama::Config]
Expand Down Expand Up @@ -232,16 +246,15 @@ 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
rescue StandardError => e
raise e
end

@issues.concat(strategy_object.issues)
@on_calculate_callbacks.each(&:call)
success?
end
Expand All @@ -263,18 +276,6 @@ def storage_manager
Y2Storage::StorageManager.instance
end

# Handle Y2Storage exceptions
def handle_exception(error)
case error
when Y2Storage::NoDiskSpaceError
@issues << failed_issue
when Y2Storage::Error
@issues << exception_issue(error)
else
raise error
end
end

# Issue representing the proposal is not valid.
#
# @return [Issue]
Expand Down

0 comments on commit 2d984ed

Please sign in to comment.