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
35
36
37
38
39
40
41
42
43
44
45
46
|
module Geo
class RepositoryDestroyService
include ::Gitlab::Geo::LogHelpers
attr_reader :id, :name, :disk_path, :repository_storage
def initialize(id, name, disk_path, repository_storage)
@id = id
@name = name
@disk_path = disk_path
@repository_storage = repository_storage
end
def async_execute
GeoRepositoryDestroyWorker.perform_async(id, name, disk_path, repository_storage)
end
def execute
destroy_project
delete_project_registry_entries
end
private
def destroy_project
::Projects::DestroyService.new(deleted_project, nil).geo_replicate
end
# rubocop: disable CodeReuse/ActiveRecord
def delete_project_registry_entries
::Geo::ProjectRegistry.where(project_id: id).delete_all
log_info("Project registry entry removed", project_id: id)
end
# rubocop: enable CodeReuse/ActiveRecord
def deleted_project
# We don't have access to the original model anymore, so we are
# rebuilding only what our service class requires
::Geo::DeletedProject.new(id: id,
name: name,
disk_path: disk_path,
repository_storage: repository_storage)
end
end
end
|