diff options
Diffstat (limited to 'app/workers/packages/debian/process_changes_worker.rb')
-rw-r--r-- | app/workers/packages/debian/process_changes_worker.rb | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/app/workers/packages/debian/process_changes_worker.rb b/app/workers/packages/debian/process_changes_worker.rb new file mode 100644 index 00000000000..edc366a7597 --- /dev/null +++ b/app/workers/packages/debian/process_changes_worker.rb @@ -0,0 +1,50 @@ +# frozen_string_literal: true + +module Packages + module Debian + class ProcessChangesWorker + include ApplicationWorker + include Gitlab::Utils::StrongMemoize + + deduplicate :until_executed + idempotent! + + queue_namespace :package_repositories + feature_category :package_registry + tags :exclude_from_kubernetes + + def perform(package_file_id, user_id) + @package_file_id = package_file_id + @user_id = user_id + + return unless package_file && user + + ::Packages::Debian::ProcessChangesService.new(package_file, user).execute + rescue ArgumentError, + Packages::Debian::ExtractChangesMetadataService::ExtractionError, + Packages::Debian::ExtractDebMetadataService::CommandFailedError, + Packages::Debian::ExtractMetadataService::ExtractionError, + Packages::Debian::ParseDebian822Service::InvalidDebian822Error, + ActiveRecord::RecordNotFound => e + Gitlab::ErrorTracking.log_exception(e, package_file_id: @package_file_id, user_id: @user_id) + package_file.destroy! + end + + private + + attr_reader :package_file_id, :user_id + + def package_file + strong_memoize(:package_file) do + ::Packages::PackageFile.find_by_id(package_file_id) + end + end + + def user + strong_memoize(:user) do + ::User.find_by_id(user_id) + end + end + end + end +end |