From f715f04c86f47d07ced75c13838e0584d605f979 Mon Sep 17 00:00:00 2001 From: Samir Jha Date: Mon, 2 Dec 2024 20:35:41 +0000 Subject: [PATCH] Fixes #38056 - Refresh content count action fails when count is set to {} --- app/models/katello/concerns/smart_proxy_extensions.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/models/katello/concerns/smart_proxy_extensions.rb b/app/models/katello/concerns/smart_proxy_extensions.rb index 12eac3bd72d..1e17000f61a 100644 --- a/app/models/katello/concerns/smart_proxy_extensions.rb +++ b/app/models/katello/concerns/smart_proxy_extensions.rb @@ -171,10 +171,10 @@ def repos_content_count(repos, reset: false) end def initialize_content_counts(reset: false) - if reset + if reset || content_counts.empty? { content_view_versions: {} }.with_indifferent_access else - (content_counts&.deep_dup || { content_view_versions: {} }).with_indifferent_access + content_counts.deep_dup.with_indifferent_access end end @@ -182,7 +182,9 @@ def process_repository(repo, content_counts) repo_mirror_service = repo.backend_service(self).with_mirror_adapter repo_content_counts = repo_mirror_service.latest_content_counts translated_counts = translate_counts(repo, repo_mirror_service, repo_content_counts) - content_counts[:content_view_versions][repo.content_view_version_id.to_s] ||= { repositories: {}} + if content_counts[:content_view_versions][repo.content_view_version_id.to_s].empty? + content_counts[:content_view_versions][repo.content_view_version_id.to_s] = { repositories: {}}.with_indifferent_access + end content_counts[:content_view_versions][repo.content_view_version_id.to_s][:repositories][repo.id.to_s] = translated_counts end