debian-mirror-gitlab/app/services/packages/generic/create_package_file_service.rb

43 lines
1.1 KiB
Ruby
Raw Normal View History

2021-01-03 14:25:43 +05:30
# frozen_string_literal: true
module Packages
module Generic
class CreatePackageFileService < BaseService
def execute
::Packages::Package.transaction do
create_package_file(find_or_create_package)
end
end
private
def find_or_create_package
package_params = {
name: params[:package_name],
version: params[:package_version],
build: params[:build]
}
2021-02-22 17:27:13 +05:30
package = ::Packages::Generic::FindOrCreatePackageService
2021-01-03 14:25:43 +05:30
.new(project, current_user, package_params)
.execute
2021-02-22 17:27:13 +05:30
package.build_infos.safe_find_or_create_by!(pipeline: params[:build].pipeline) if params[:build].present?
package
2021-01-03 14:25:43 +05:30
end
def create_package_file(package)
file_params = {
file: params[:file],
size: params[:file].size,
file_sha256: params[:file].sha256,
2021-01-29 00:20:46 +05:30
file_name: params[:file_name],
build: params[:build]
2021-01-03 14:25:43 +05:30
}
::Packages::CreatePackageFileService.new(package, file_params).execute
end
end
end
end