blob: 3b2be7b6874806db2c3d7ffee185263338c79617 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# frozen_string_literal: true
module Packages
module Debian
class FindOrCreatePackageService < ::Packages::CreatePackageService
include Gitlab::Utils::StrongMemoize
def execute
package = project.packages
.debian
.with_name(params[:name])
.with_version(params[:version])
.with_debian_codename(params[:distribution_name])
.not_pending_destruction
.first
package ||= create_package!(
:debian,
debian_publication_attributes: { distribution_id: distribution.id }
)
ServiceResponse.success(payload: { package: package })
end
private
def distribution
strong_memoize(:distribution) do
Packages::Debian::DistributionsFinder.new(project, codename: params[:distribution_name]).execute.last!
end
end
end
end
end
|