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

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

39 lines
1.1 KiB
Ruby
Raw Normal View History

2020-07-28 23:09:34 +05:30
# frozen_string_literal: true
module Packages
module Conan
class CreatePackageFileService
attr_reader :package, :file, :params
def initialize(package, file, params)
@package = package
@file = file
@params = params
end
def execute
2021-02-22 17:27:13 +05:30
package_file = package.package_files.build(
2022-08-27 11:52:29 +05:30
file: file,
size: params['file.size'],
2020-07-28 23:09:34 +05:30
file_name: params[:file_name],
file_sha1: params['file.sha1'],
2022-08-27 11:52:29 +05:30
file_md5: params['file.md5'],
2020-07-28 23:09:34 +05:30
conan_file_metadatum_attributes: {
recipe_revision: params[:recipe_revision],
package_revision: params[:package_revision],
conan_package_reference: params[:conan_package_reference],
conan_file_type: params[:conan_file_type]
}
)
2021-02-22 17:27:13 +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
end