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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

30 lines
731 B
Ruby
Raw Normal View History

2020-07-28 23:09:34 +05:30
# frozen_string_literal: true
module Packages
class CreatePackageFileService
attr_reader :package, :params
def initialize(package, params)
@package = package
@params = params
end
def execute
2021-01-29 00:20:46 +05:30
package_file = package.package_files.build(
2022-08-27 11:52:29 +05:30
file: params[:file],
size: params[:size],
file_name: params[:file_name],
file_sha1: params[:file_sha1],
2020-07-28 23:09:34 +05:30
file_sha256: params[:file_sha256],
2022-08-27 11:52:29 +05:30
file_md5: params[:file_md5]
2020-07-28 23:09:34 +05:30
)
2021-01-29 00:20:46 +05:30
if params[:build].present?
package_file.package_file_build_infos << package_file.package_file_build_infos.build(pipeline: params[:build].pipeline)
end
package_file.save!
package_file
2020-07-28 23:09:34 +05:30
end
end
end