-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #36563 - Move remove orphan content units to async task
- Loading branch information
Showing
5 changed files
with
39 additions
and
4 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
app/lib/actions/katello/orphan_cleanup/remove_orphaned_content_units.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module Actions | ||
module Katello | ||
module OrphanCleanup | ||
class RemoveOrphanedContentUnits < Actions::Base | ||
def plan(options = {}) | ||
plan_self(id: options[:repo_id], destroy_all: options[:destroy_all]) | ||
end | ||
|
||
def run | ||
content_types_to_index = [] | ||
if input[:destroy_all] | ||
::Katello::RepositoryTypeManager.enabled_repository_types.each_value do |repo_type| | ||
content_types_to_index << repo_type.content_types_to_index | ||
end | ||
elsif input[:id] | ||
repo = ::Katello::Repository.find(input[:id]) | ||
content_types_to_index = repo.repository_type.content_types_to_index | ||
else | ||
fail "Pass either a repository to determine content type or destroy_all to destroy all orphaned content units" | ||
end | ||
content_types_to_index.flatten.each do |type| | ||
type.model_class.orphaned.destroy_all | ||
end | ||
end | ||
|
||
def rescue_strategy | ||
Dynflow::Action::Rescue::Skip | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters