Class: Packages::Debian::ProcessPackageFileService

Inherits:
Object
  • Object
show all
Includes:
ExclusiveLeaseGuard, Gitlab::Utils::StrongMemoize
Defined in:
app/services/packages/debian/process_package_file_service.rb

Constant Summary collapse

SOURCE_FIELD_SPLIT_REGEX =
/[ ()]/
DEFAULT_LEASE_TIMEOUT =

used by ExclusiveLeaseGuard

1.hour.to_i.freeze
SIMPLE_DEB_FILE_TYPES =
%i[deb udeb ddeb].freeze

Instance Method Summary collapse

Methods included from ExclusiveLeaseGuard

#exclusive_lease, #lease_release?, #lease_taken_log_level, #lease_taken_message, #log_lease_taken, #release_lease, #renew_lease!, #try_obtain_lease

Constructor Details

#initialize(package_file, distribution_name, component_name) ⇒ ProcessPackageFileService

Returns a new instance of ProcessPackageFileService.



15
16
17
18
19
# File 'app/services/packages/debian/process_package_file_service.rb', line 15

def initialize(package_file, distribution_name, component_name)
  @package_file = package_file
  @distribution_name = distribution_name
  @component_name = component_name
end

Instance Method Details

#executeObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/services/packages/debian/process_package_file_service.rb', line 21

def execute
  return if @package_file.package.pending_destruction?

  validate!

  try_obtain_lease do
    distribution.transaction do
      rename_package_and_set_version
      update_package
       if changes_file?
      
      cleanup_temp_package
    end

    ::Packages::Debian::GenerateDistributionWorker.perform_async(:project, package.debian_distribution.id)
  end
end