gitlab-org--gitlab-foss/app/services/packages/debian/create_package_file_service.rb

39 lines
1.1 KiB
Ruby

# frozen_string_literal: true
module Packages
module Debian
class CreatePackageFileService
include ::Packages::FIPS
def initialize(package, params)
@package = package
@params = params
end
def execute
raise DisabledError, 'Debian registry is not FIPS compliant' if Gitlab::FIPS.enabled?
raise ArgumentError, "Invalid package" unless package.present?
# Debian package file are first uploaded to incoming with empty metadata,
# and are moved later by Packages::Debian::ProcessChangesService
package.package_files.create!(
file: params[:file],
size: params[:file]&.size,
file_name: params[:file_name],
file_sha1: params[:file_sha1],
file_sha256: params[:file]&.sha256,
file_md5: params[:file_md5],
debian_file_metadatum_attributes: {
file_type: 'unknown',
architecture: nil,
fields: nil
}
)
end
private
attr_reader :package, :params
end
end
end